In [2]:
import requests
import csv

# Define the API endpoint and parameters
url = "https://www.alphavantage.co/query"
params = {
    "function": "TIME_SERIES_DAILY",
    "symbol": "AAPL",
    "outputsize": "full",
    "apikey": "BCM8XKDANVYM524G"
}

# Send the API request
response = requests.get(url, params=params)
data = response.json()

# Extract the daily stock data
time_series = data["Time Series (Daily)"]

# Write the data to a CSV file
with open("stock_data.csv", "w", newline="") as csvfile:
    writer = csv.writer(csvfile)
    writer.writerow(["Date", "Open", "High", "Low", "Close", "Volume"])
    for date, values in time_series.items():
        writer.writerow([date, values["1. open"], values["2. high"], values["3. low"], values["4. close"], values["5. volume"]])
In [24]:
import requests
import csv 

# Define the API endpoint and parameters
url = "https://www.alphavantage.co/query"
params = {
    "function": "TIME_SERIES_DAILY",
    "symbol": "AAPL",
    "outputsize": "full",
    "apikey": "BCM8XKDANVYM524G"
}

# Send the API request
response = requests.get(url, params=params)
data = response.json()

# Extract the daily stock data
time_series = data["Time Series (Daily)"]

# Write the data to a CSV file
csv_file_path = "C:\\Users\\Alex\\stock_data.csv"
with open(csv_file_path, "w", newline="") as csvfile:
    writer = csv.writer(csvfile)
    writer.writerow(["Date", "Open", "High", "Low", "Close", "Volume"])
    for date, values in time_series.items():
        writer.writerow([date, values["1. open"], values["2. high"], values["3. low"], values["4. close"], values["5. volume"]])

print(f"CSV file saved to: {csv_file_path}")
CSV file saved to: C:\Users\Alex\stock_data.csv
In [ ]:
 
In [5]:
import requests
import csv

# Define the list of companies and their symbols
companies = {
    "Reliance Industries Limited (RELIANCE)": "RELIANCE",
    "Tata Consultancy Services Limited (TCS)": "TCS",
    "Housing Development Finance Corporation Limited (HDFC)": "HDFC",
    "Infosys Limited (INFY)": "INFY",
    "State Bank of India (SBIN)": "SBIN",
    "ICICI Bank Limited (ICICIBANK)": "ICICIBANK",
    "Larsen & Toubro Limited (LT)": "LT",
    "HDFC Bank Limited (HDFCBANK)": "HDFCBANK",
    "Bharti Airtel Limited (BHARTIARTL)": "BHARTIARTL",
    "Axis Bank Limited (AXISBANK)": "AXISBANK"
}

# Define the base API endpoint and your API key
url = "https://www.alphavantage.co/query"
apikey = "BCM8XKDANVYM524G"

# Iterate over each company and download its stock data
for company, symbol in companies.items():
    params = {
        "function": "TIME_SERIES_DAILY",
        "symbol": symbol,
        "outputsize": "full",
        "apikey": apikey
    }
    
    # Send the API request
    response = requests.get(url, params=params)
    data = response.json()
    
    # Check if "Time Series (Daily)" key is present in the response
    if "Time Series (Daily)" not in data:
        print(f"No data found for {company}")
        continue
    
    # Extract the daily stock data
    time_series = data["Time Series (Daily)"]
    
    # Write the data to a CSV file
    csv_file_path = f"C:\\Users\\Alex\\{symbol}_stock_data.csv"
    with open(csv_file_path, "w", newline="") as csvfile:
        writer = csv.writer(csvfile)
        writer.writerow(["Date", "Open", "High", "Low", "Close", "Volume"])
        for date, values in time_series.items():
            writer.writerow([date, values["1. open"], values["2. high"], values["3. low"], values["4. close"], values["5. volume"]])
    
    print(f"Stock data for {company} saved to: {csv_file_path}")
No data found for Reliance Industries Limited (RELIANCE)
Stock data for Tata Consultancy Services Limited (TCS) saved to: C:\Users\Alex\TCS_stock_data.csv
No data found for Housing Development Finance Corporation Limited (HDFC)
Stock data for Infosys Limited (INFY) saved to: C:\Users\Alex\INFY_stock_data.csv
No data found for State Bank of India (SBIN)
No data found for ICICI Bank Limited (ICICIBANK)
No data found for Larsen & Toubro Limited (LT)
No data found for HDFC Bank Limited (HDFCBANK)
No data found for Bharti Airtel Limited (BHARTIARTL)
No data found for Axis Bank Limited (AXISBANK)
In [6]:
import requests
import csv

# Define the list of companies and their symbols
companies = {
    "Apple Inc. (AAPL)": "AAPL",
    "Microsoft Corporation (MSFT)": "MSFT",
    "Amazon.com Inc. (AMZN)": "AMZN",
    "Alphabet Inc. (GOOGL)": "GOOGL",
    "Facebook, Inc. (FB)": "FB",
    "Tesla, Inc. (TSLA)": "TSLA",
    "Nvidia Corporation (NVDA)": "NVDA",
    "The Walt Disney Company (DIS)": "DIS",
    "Visa Inc. (V)": "V",
    "Johnson & Johnson (JNJ)": "JNJ"
}

# Define the base API endpoint and your API key
url = "https://www.alphavantage.co/query"
apikey = "BCM8XKDANVYM524G"  # Replace 'YOUR_API_KEY' with your actual Alpha Vantage API key

# Iterate over each company and download its stock data
for company, symbol in companies.items():
    params = {
        "function": "TIME_SERIES_DAILY",
        "symbol": symbol,
        "outputsize": "full",
        "apikey": apikey
    }
    
    # Send the API request
    response = requests.get(url, params=params)
    data = response.json()
    
    # Check if "Time Series (Daily)" key is present in the response
    if "Time Series (Daily)" not in data:
        print(f"No data found for {company}")
        continue
    
    # Extract the daily stock data
    time_series = data["Time Series (Daily)"]
    
    # Write the data to a CSV file
    csv_file_path = f"{symbol}_stock_data.csv"
    with open(csv_file_path, "w", newline="") as csvfile:
        writer = csv.writer(csvfile)
        writer.writerow(["Date", "Open", "High", "Low", "Close", "Volume"])
        for date, values in time_series.items():
            writer.writerow([date, values["1. open"], values["2. high"], values["3. low"], values["4. close"], values["5. volume"]])
    }")

    print(f"Stock data for {company} saved to: {csv_file_path
Stock data for Apple Inc. (AAPL) saved to: AAPL_stock_data.csv
Stock data for Microsoft Corporation (MSFT) saved to: MSFT_stock_data.csv
Stock data for Amazon.com Inc. (AMZN) saved to: AMZN_stock_data.csv
Stock data for Alphabet Inc. (GOOGL) saved to: GOOGL_stock_data.csv
No data found for Facebook, Inc. (FB)
Stock data for Tesla, Inc. (TSLA) saved to: TSLA_stock_data.csv
Stock data for Nvidia Corporation (NVDA) saved to: NVDA_stock_data.csv
Stock data for The Walt Disney Company (DIS) saved to: DIS_stock_data.csv
No data found for Visa Inc. (V)
No data found for Johnson & Johnson (JNJ)
In [7]:
import requests

url = "https://example.com/path/to/your/csv/file/Data%20Sheet.csv"  # Replace this URL with the actual URL of your CSV file
file_path = r"C:\Users\Alex\Downloads\Data Sheet.csv"  # Specify the local file path where you want to save the downloaded CSV file

response = requests.get(url)

if response.status_code == 200:
    with open(file_path, 'wb') as f:
        f.write(response.content)
    print("CSV file downloaded successfully!")
else:
    print("Failed to download CSV file. Status code:", response.status_code)
Failed to download CSV file. Status code: 500
In [8]:
import requests
import csv

# Define the list of companies and their symbols
companies = {
    "Apple Inc. (AAPL)": "AAPL",
    "Microsoft Corporation (MSFT)": "MSFT",
    "Amazon.com Inc. (AMZN)": "AMZN",
    "Alphabet Inc. (GOOGL)": "GOOGL",
    "Facebook, Inc. (FB)": "FB",
    "Tesla, Inc. (TSLA)": "TSLA",
    "Nvidia Corporation (NVDA)": "NVDA",
    "The Walt Disney Company (DIS)": "DIS",
    "Visa Inc. (V)": "V",
    "Johnson & Johnson (JNJ)": "JNJ"
}

# Define the base API endpoint and your API key
url = "https://www.alphavantage.co/query"
apikey = "BCM8XKDANVYM524G"  # Replace 'YOUR_API_KEY' with your actual Alpha Vantage API key

# Iterate over each company and download its stock data
for company, symbol in companies.items():
    params = {
        "function": "TIME_SERIES_DAILY",
        "symbol": symbol,
        "outputsize": "full",
        "apikey": apikey
    }
    
    # Send the API request
    response = requests.get(url, params=params)
    data = response.json()
    
    # Check if "Time Series (Daily)" key is present in the response
    if "Time Series (Daily)" not in data:
        print(f"No data found for {company}")
        continue
    
    # Extract the daily stock data
    time_series = data["Time Series (Daily)"]
    
    # Write the data to a CSV file
    csv_file_path = f"{symbol}_stock_data.csv"
    with open(csv_file_path, "w", newline="") as csvfile:
        writer = csv.writer(csvfile)
        writer.writerow(["Date", "Open", "High", "Low", "Close", "Volume"])
        for date, values in time_series.items():
            writer.writerow([date, values["1. open"], values["2. high"], values["3. low"], values["4. close"], values["5. volume"]])
    
    print(f"Stock data for {company} saved to: {csv_file_path}")
No data found for Apple Inc. (AAPL)
No data found for Microsoft Corporation (MSFT)
No data found for Amazon.com Inc. (AMZN)
No data found for Alphabet Inc. (GOOGL)
No data found for Facebook, Inc. (FB)
No data found for Tesla, Inc. (TSLA)
No data found for Nvidia Corporation (NVDA)
No data found for The Walt Disney Company (DIS)
No data found for Visa Inc. (V)
No data found for Johnson & Johnson (JNJ)
In [9]:
import requests
import csv

# Define the list of top Indian companies and their symbols
indian_companies = {
    "Reliance Industries Ltd.": "RELIANCE.NS",
    "Tata Consultancy Services Ltd.": "TCS.NS",
    "HDFC Bank Ltd.": "HDFCBANK.NS",
    "Hindustan Unilever Ltd.": "HINDUNILVR.NS",
    "Infosys Ltd.": "INFY.NS",
    "ICICI Bank Ltd.": "ICICIBANK.NS",
    "Kotak Mahindra Bank Ltd.": "KOTAKBANK.NS",
    "Housing Development Finance Corporation Ltd.": "HDFC.NS",
    "Bharti Airtel Ltd.": "BHARTIARTL.NS",
    "Axis Bank Ltd.": "AXISBANK.NS"
}

# Define the base API endpoint and your API key
url = "https://www.alphavantage.co/query"
apikey = "YOUR_API_KEY"  # Replace 'YOUR_API_KEY' with your actual Alpha Vantage API key

# Iterate over each company and download its stock data
for company, symbol in indian_companies.items():
    params = {
        "function": "TIME_SERIES_DAILY",
        "symbol": symbol,
        "outputsize": "full",
        "apikey": apikey
    }
    
    # Send the API request
    response = requests.get(url, params=params)
    data = response.json()
    
    # Check if "Time Series (Daily)" key is present in the response
    if "Time Series (Daily)" not in data:
        print(f"No data found for {company}")
        continue
    
    # Extract the daily stock data
    time_series = data["Time Series (Daily)"]
    
    # Write the data to a CSV file
    csv_file_path = f"{symbol}_stock_data.csv"
    with open(csv_file_path, "w", newline="") as csvfile:
        writer = csv.writer(csvfile)
        writer.writerow(["Date", "Open", "High", "Low", "Close", "Volume"])
        for date, values in time_series.items():
            writer.writerow([date, values["1. open"], values["2. high"], values["3. low"], values["4. close"], values["5. volume"]])
    
    print(f"Stock data for {company} saved to: {csv_file_path}")
No data found for Reliance Industries Ltd.
No data found for Tata Consultancy Services Ltd.
No data found for HDFC Bank Ltd.
No data found for Hindustan Unilever Ltd.
No data found for Infosys Ltd.
No data found for ICICI Bank Ltd.
No data found for Kotak Mahindra Bank Ltd.
No data found for Housing Development Finance Corporation Ltd.
No data found for Bharti Airtel Ltd.
No data found for Axis Bank Ltd.
In [11]:
import requests
import csv

# Define the list of top Indian companies and their symbols
indian_companies = {
    "Reliance Industries Ltd.": "RELIANCE.NS",
    "Tata Consultancy Services Ltd.": "TCS.NS",
    "HDFC Bank Ltd.": "HDFCBANK.NS",
    "Hindustan Unilever Ltd.": "HINDUNILVR.NS",
    "Infosys Ltd.": "INFY.NS",
    "ICICI Bank Ltd.": "ICICIBANK.NS",
    "Kotak Mahindra Bank Ltd.": "KOTAKBANK.NS",
    "Housing Development Finance Corporation Ltd.": "HDFC.NS",
    "Bharti Airtel Ltd.": "BHARTIARTL.NS",
    "Axis Bank Ltd.": "AXISBANK.NS"
}

# Define the base API endpoint and your API key
url = "https://www.alphavantage.co/query"
apikey = "MXUAMZ0SSVRZC6JL"  # Replace 'YOUR_API_KEY' with your actual Alpha Vantage API key

# Iterate over each company and download its stock data
for company, symbol in indian_companies.items():
    params = {
        "function": "TIME_SERIES_DAILY",
        "symbol": symbol,
        "outputsize": "full",
        "apikey": apikey
    }
    
    # Send the API request
    response = requests.get(url, params=params)
    data = response.json()
    
    # Check if "Time Series (Daily)" key is present in the response
    if "Time Series (Daily)" not in data:
        print(f"No data found for {company}")
        continue
    
    # Extract the daily stock data
    time_series = data["Time Series (Daily)"]
    
    # Write the data to a CSV file
    csv_file_path = f"{symbol}_stock_data.csv"
    with open(csv_file_path, "w", newline="") as csvfile:
        writer = csv.writer(csvfile)
        writer.writerow(["Date", "Open", "High", "Low", "Close", "Volume"])
        for date, values in time_series.items():
            writer.writerow([date, values["1. open"], values["2. high"], values["3. low"], values["4. close"], values["5. volume"]])
    
    print(f"Stock data for {company} saved to: {csv_file_path}")
No data found for Reliance Industries Ltd.
No data found for Tata Consultancy Services Ltd.
No data found for HDFC Bank Ltd.
No data found for Hindustan Unilever Ltd.
No data found for Infosys Ltd.
No data found for ICICI Bank Ltd.
No data found for Kotak Mahindra Bank Ltd.
No data found for Housing Development Finance Corporation Ltd.
No data found for Bharti Airtel Ltd.
No data found for Axis Bank Ltd.
In [12]:
import requests
import csv

# Define the list of top Indian companies and their symbols
indian_companies = {
    "State Bank of India": "SBIN.NS",
    "Hindalco Industries Ltd.": "HINDALCO.NS",
    "ITC Ltd.": "ITC.NS",
    "Adani Ports and Special Economic Zone Ltd.": "ADANIPORTS.NS",
    "Mahindra & Mahindra Ltd.": "M&M.NS"
}

# Define the base API endpoint and your API key
url = "https://www.alphavantage.co/query"
apikey = "MXUAMZ0SSVRZC6JL"

# Iterate over each company and download its stock data
for company, symbol in indian_companies.items():
    params = {
        "function": "TIME_SERIES_DAILY",
        "symbol": symbol,
        "outputsize": "full",
        "apikey": apikey
    }
    
    # Send the API request
    response = requests.get(url, params=params)
    data = response.json()
    
    # Check if "Time Series (Daily)" key is present in the response
    if "Time Series (Daily)" not in data:
        print(f"No data found for {company}")
        continue
    
    # Extract the daily stock data
    time_series = data["Time Series (Daily)"]
    
    # Write the data to a CSV file
    csv_file_path = f"{symbol}_stock_data.csv"
    with open(csv_file_path, "w", newline="") as csvfile:
        writer = csv.writer(csvfile)
        writer.writerow(["Date", "Open", "High", "Low", "Close", "Volume"])
        for date, values in time_series.items():
            writer.writerow([date, values["1. open"], values["2. high"], values["3. low"], values["4. close"], values["5. volume"]])
    
    print(f"Stock data for {company} saved to: {csv_file_path}")
No data found for State Bank of India
No data found for Hindalco Industries Ltd.
No data found for ITC Ltd.
No data found for Adani Ports and Special Economic Zone Ltd.
No data found for Mahindra & Mahindra Ltd.
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [25]:
import pandas_datareader.data as web

# Download historical data for a stock from Yahoo Finance
data = web.DataReader('AAPL', 'yahoo', start='2022-01-01', end='2022-12-31')

# Display the first few rows of the data
print(data.head())
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[25], line 4
      1 import pandas_datareader.data as web
      3 # Download historical data for a stock from Yahoo Finance
----> 4 data = web.DataReader('AAPL', 'yahoo', start='2022-01-01', end='2022-12-31')
      6 # Display the first few rows of the data
      7 print(data.head())

File D:\New folder\Lib\site-packages\pandas\util\_decorators.py:211, in deprecate_kwarg.<locals>._deprecate_kwarg.<locals>.wrapper(*args, **kwargs)
    209     else:
    210         kwargs[new_arg_name] = new_arg_value
--> 211 return func(*args, **kwargs)

File D:\New folder\Lib\site-packages\pandas_datareader\data.py:379, in DataReader(name, data_source, start, end, retry_count, pause, session, api_key)
    367     raise NotImplementedError(msg)
    369 if data_source == "yahoo":
    370     return YahooDailyReader(
    371         symbols=name,
    372         start=start,
    373         end=end,
    374         adjust_price=False,
    375         chunksize=25,
    376         retry_count=retry_count,
    377         pause=pause,
    378         session=session,
--> 379     ).read()
    381 elif data_source == "iex":
    382     return IEXDailyReader(
    383         symbols=name,
    384         start=start,
   (...)
    390         session=session,
    391     ).read()

File D:\New folder\Lib\site-packages\pandas_datareader\base.py:253, in _DailyBaseReader.read(self)
    251 # If a single symbol, (e.g., 'GOOG')
    252 if isinstance(self.symbols, (string_types, int)):
--> 253     df = self._read_one_data(self.url, params=self._get_params(self.symbols))
    254 # Or multiple symbols, (e.g., ['GOOG', 'AAPL', 'MSFT'])
    255 elif isinstance(self.symbols, DataFrame):

File D:\New folder\Lib\site-packages\pandas_datareader\yahoo\daily.py:152, in YahooDailyReader._read_one_data(self, url, params)
    150 ptrn = r"root\.App\.main = (.*?);\n}\(this\)\);"
    151 try:
--> 152     j = json.loads(re.search(ptrn, resp.text, re.DOTALL).group(1))
    153     data = j["context"]["dispatcher"]["stores"]["HistoricalPriceStore"]
    154 except KeyError:

AttributeError: 'NoneType' object has no attribute 'group'
In [1]:
pip install pandas-datareader
Requirement already satisfied: pandas-datareader in d:\new folder\lib\site-packages (0.10.0)Note: you may need to restart the kernel to use updated packages.

Requirement already satisfied: lxml in d:\new folder\lib\site-packages (from pandas-datareader) (4.9.2)
Requirement already satisfied: pandas>=0.23 in d:\new folder\lib\site-packages (from pandas-datareader) (1.5.3)
Requirement already satisfied: requests>=2.19.0 in d:\new folder\lib\site-packages (from pandas-datareader) (2.31.0)
Requirement already satisfied: python-dateutil>=2.8.1 in d:\new folder\lib\site-packages (from pandas>=0.23->pandas-datareader) (2.8.2)
Requirement already satisfied: pytz>=2020.1 in d:\new folder\lib\site-packages (from pandas>=0.23->pandas-datareader) (2022.7)
Requirement already satisfied: numpy>=1.21.0 in d:\new folder\lib\site-packages (from pandas>=0.23->pandas-datareader) (1.24.3)
Requirement already satisfied: charset-normalizer<4,>=2 in d:\new folder\lib\site-packages (from requests>=2.19.0->pandas-datareader) (2.0.4)
Requirement already satisfied: idna<4,>=2.5 in d:\new folder\lib\site-packages (from requests>=2.19.0->pandas-datareader) (3.4)
Requirement already satisfied: urllib3<3,>=1.21.1 in d:\new folder\lib\site-packages (from requests>=2.19.0->pandas-datareader) (1.26.16)
Requirement already satisfied: certifi>=2017.4.17 in d:\new folder\lib\site-packages (from requests>=2.19.0->pandas-datareader) (2023.7.22)
Requirement already satisfied: six>=1.5 in d:\new folder\lib\site-packages (from python-dateutil>=2.8.1->pandas>=0.23->pandas-datareader) (1.16.0)
In [ ]:
 
In [3]:
import pandas_datareader.data as web

# Define the list of Indian companies and their corresponding stock symbols
indian_companies = {
    "Reliance Industries Ltd.": "RELIANCE.NS",
    "Tata Consultancy Services Ltd.": "TCS.NS",
    "HDFC Bank Ltd.": "HDFCBANK.NS",
    "Hindustan Unilever Ltd.": "HINDUNILVR.NS",
    "Infosys Ltd.": "INFY.NS",
    "ICICI Bank Ltd.": "ICICIBANK.NS",
    "Kotak Mahindra Bank Ltd.": "KOTAKBANK.NS",
    "Housing Development Finance Corporation Ltd.": "HDFC.NS",
    "Bharti Airtel Ltd.": "BHARTIARTL.NS",
    "Axis Bank Ltd.": "AXISBANK.NS"
}

# Initialize an empty dictionary to store data for each company
company_data = {}

# Iterate over each company and download historical data
for company, symbol in indian_companies.items():
    try:
        data = web.DataReader(symbol, 'yahoo', start='2022-01-01', end='2022-12-31')
        company_data[company] = data
        print(f"Downloaded data for {company}")
    except Exception as e:
        print(f"Error downloading data for {company}: {e}")

# Access and display the first few rows of data for each company
for company, data in company_data.items():
    print(f"\nStock data for {company}:")
    print(data.head())
Error downloading data for Reliance Industries Ltd.: 'NoneType' object has no attribute 'group'
Error downloading data for Tata Consultancy Services Ltd.: 'NoneType' object has no attribute 'group'
Error downloading data for HDFC Bank Ltd.: 'NoneType' object has no attribute 'group'
Error downloading data for Hindustan Unilever Ltd.: 'NoneType' object has no attribute 'group'
Error downloading data for Infosys Ltd.: 'NoneType' object has no attribute 'group'
Error downloading data for ICICI Bank Ltd.: 'NoneType' object has no attribute 'group'
Error downloading data for Kotak Mahindra Bank Ltd.: 'NoneType' object has no attribute 'group'
Error downloading data for Housing Development Finance Corporation Ltd.: 'NoneType' object has no attribute 'group'
Error downloading data for Bharti Airtel Ltd.: 'NoneType' object has no attribute 'group'
Error downloading data for Axis Bank Ltd.: 'NoneType' object has no attribute 'group'
In [ ]:
 
In [5]:
!pip install yfinance
Collecting yfinance
  Obtaining dependency information for yfinance from https://files.pythonhosted.org/packages/d5/b5/70bb98ee38ce532ee29fab76fb668382291fe6e1aa69a8c1ac7e6bc108e7/yfinance-0.2.38-py2.py3-none-any.whl.metadata
  Downloading yfinance-0.2.38-py2.py3-none-any.whl.metadata (11 kB)
Requirement already satisfied: pandas>=1.3.0 in d:\new folder\lib\site-packages (from yfinance) (1.5.3)
Requirement already satisfied: numpy>=1.16.5 in d:\new folder\lib\site-packages (from yfinance) (1.24.3)
Requirement already satisfied: requests>=2.31 in d:\new folder\lib\site-packages (from yfinance) (2.31.0)
Collecting multitasking>=0.0.7 (from yfinance)
  Obtaining dependency information for multitasking>=0.0.7 from https://files.pythonhosted.org/packages/3e/8a/bb3160e76e844db9e69a413f055818969c8acade64e1a9ac5ce9dfdcf6c1/multitasking-0.0.11-py3-none-any.whl.metadata
  Downloading multitasking-0.0.11-py3-none-any.whl.metadata (5.5 kB)
Requirement already satisfied: lxml>=4.9.1 in d:\new folder\lib\site-packages (from yfinance) (4.9.2)
Requirement already satisfied: appdirs>=1.4.4 in d:\new folder\lib\site-packages (from yfinance) (1.4.4)
Requirement already satisfied: pytz>=2022.5 in d:\new folder\lib\site-packages (from yfinance) (2022.7)
Collecting frozendict>=2.3.4 (from yfinance)
  Downloading frozendict-2.4.2.tar.gz (315 kB)
     ---------------------------------------- 0.0/315.3 kB ? eta -:--:--
     --- ------------------------------------ 30.7/315.3 kB ? eta -:--:--
     ---- -------------------------------- 41.0/315.3 kB 393.8 kB/s eta 0:00:01
     ------- ----------------------------- 61.4/315.3 kB 656.4 kB/s eta 0:00:01
     ------- ----------------------------- 61.4/315.3 kB 656.4 kB/s eta 0:00:01
     ------- ----------------------------- 61.4/315.3 kB 656.4 kB/s eta 0:00:01
     ----------------- ------------------ 153.6/315.3 kB 612.6 kB/s eta 0:00:01
     ----------------------- ------------ 204.8/315.3 kB 692.4 kB/s eta 0:00:01
     -------------------------- --------- 235.5/315.3 kB 686.8 kB/s eta 0:00:01
     -------------------------------- --- 286.7/315.3 kB 737.3 kB/s eta 0:00:01
     ------------------------------------ 315.3/315.3 kB 722.8 kB/s eta 0:00:00
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Preparing metadata (pyproject.toml): started
  Preparing metadata (pyproject.toml): finished with status 'done'
Collecting peewee>=3.16.2 (from yfinance)
  Downloading peewee-3.17.3.tar.gz (3.0 MB)
     ---------------------------------------- 0.0/3.0 MB ? eta -:--:--
     ---------------------------------------- 0.0/3.0 MB ? eta -:--:--
      --------------------------------------- 0.1/3.0 MB 871.5 kB/s eta 0:00:04
      --------------------------------------- 0.1/3.0 MB 653.6 kB/s eta 0:00:05
     - -------------------------------------- 0.1/3.0 MB 654.9 kB/s eta 0:00:05
     - -------------------------------------- 0.1/3.0 MB 654.9 kB/s eta 0:00:05
     - -------------------------------------- 0.1/3.0 MB 654.9 kB/s eta 0:00:05
     -- ------------------------------------- 0.2/3.0 MB 517.2 kB/s eta 0:00:06
     -- ------------------------------------- 0.2/3.0 MB 517.2 kB/s eta 0:00:06
     -- ------------------------------------- 0.2/3.0 MB 445.2 kB/s eta 0:00:07
     -- ------------------------------------- 0.2/3.0 MB 445.2 kB/s eta 0:00:07
     -- ------------------------------------- 0.2/3.0 MB 380.0 kB/s eta 0:00:08
     -- ------------------------------------- 0.2/3.0 MB 380.0 kB/s eta 0:00:08
     --- ------------------------------------ 0.3/3.0 MB 424.5 kB/s eta 0:00:07
     --- ------------------------------------ 0.3/3.0 MB 424.5 kB/s eta 0:00:07
     ---- ----------------------------------- 0.3/3.0 MB 436.4 kB/s eta 0:00:07
     ---- ----------------------------------- 0.3/3.0 MB 455.7 kB/s eta 0:00:06
     ---- ----------------------------------- 0.3/3.0 MB 455.7 kB/s eta 0:00:06
     ----- ---------------------------------- 0.4/3.0 MB 462.5 kB/s eta 0:00:06
     ----- ---------------------------------- 0.4/3.0 MB 462.5 kB/s eta 0:00:06
     ----- ---------------------------------- 0.4/3.0 MB 474.2 kB/s eta 0:00:06
     ------ --------------------------------- 0.5/3.0 MB 475.5 kB/s eta 0:00:06
     ------- -------------------------------- 0.5/3.0 MB 524.1 kB/s eta 0:00:05
     ------- -------------------------------- 0.5/3.0 MB 524.1 kB/s eta 0:00:05
     ------- -------------------------------- 0.6/3.0 MB 488.9 kB/s eta 0:00:05
     ------- -------------------------------- 0.6/3.0 MB 488.9 kB/s eta 0:00:05
     -------- ------------------------------- 0.6/3.0 MB 504.0 kB/s eta 0:00:05
     -------- ------------------------------- 0.6/3.0 MB 504.0 kB/s eta 0:00:05
     -------- ------------------------------- 0.6/3.0 MB 504.0 kB/s eta 0:00:05
     -------- ------------------------------- 0.6/3.0 MB 504.0 kB/s eta 0:00:05
     -------- ------------------------------- 0.6/3.0 MB 504.0 kB/s eta 0:00:05
     --------- ------------------------------ 0.7/3.0 MB 470.0 kB/s eta 0:00:05
     --------- ------------------------------ 0.7/3.0 MB 470.0 kB/s eta 0:00:05
     --------- ------------------------------ 0.7/3.0 MB 470.0 kB/s eta 0:00:05
     ---------- ----------------------------- 0.8/3.0 MB 488.2 kB/s eta 0:00:05
     ---------- ----------------------------- 0.8/3.0 MB 489.7 kB/s eta 0:00:05
     ------------ --------------------------- 0.9/3.0 MB 527.8 kB/s eta 0:00:04
     ------------ --------------------------- 0.9/3.0 MB 536.1 kB/s eta 0:00:04
     ------------- -------------------------- 1.0/3.0 MB 551.6 kB/s eta 0:00:04
     -------------- ------------------------- 1.0/3.0 MB 559.9 kB/s eta 0:00:04
     -------------- ------------------------- 1.1/3.0 MB 578.9 kB/s eta 0:00:04
     --------------- ------------------------ 1.1/3.0 MB 596.0 kB/s eta 0:00:04
     ---------------- ----------------------- 1.2/3.0 MB 608.5 kB/s eta 0:00:03
     ---------------- ----------------------- 1.2/3.0 MB 614.4 kB/s eta 0:00:03
     ----------------- ---------------------- 1.3/3.0 MB 620.5 kB/s eta 0:00:03
     ----------------- ---------------------- 1.3/3.0 MB 630.5 kB/s eta 0:00:03
     ------------------ --------------------- 1.4/3.0 MB 640.9 kB/s eta 0:00:03
     ------------------- -------------------- 1.5/3.0 MB 659.9 kB/s eta 0:00:03
     ------------------- -------------------- 1.5/3.0 MB 659.9 kB/s eta 0:00:03
     -------------------- ------------------- 1.5/3.0 MB 664.2 kB/s eta 0:00:03
     --------------------- ------------------ 1.6/3.0 MB 681.2 kB/s eta 0:00:02
     ---------------------- ----------------- 1.6/3.0 MB 689.9 kB/s eta 0:00:02
     ----------------------- ---------------- 1.8/3.0 MB 709.4 kB/s eta 0:00:02
     ------------------------ --------------- 1.8/3.0 MB 716.8 kB/s eta 0:00:02
     ------------------------ --------------- 1.8/3.0 MB 719.7 kB/s eta 0:00:02
     ------------------------- -------------- 1.9/3.0 MB 726.4 kB/s eta 0:00:02
     -------------------------- ------------- 2.0/3.0 MB 740.6 kB/s eta 0:00:02
     --------------------------- ------------ 2.1/3.0 MB 761.9 kB/s eta 0:00:02
     ---------------------------- ----------- 2.1/3.0 MB 767.5 kB/s eta 0:00:02
     ----------------------------- ---------- 2.2/3.0 MB 784.0 kB/s eta 0:00:01
     ------------------------------ --------- 2.3/3.0 MB 796.3 kB/s eta 0:00:01
     ------------------------------- -------- 2.3/3.0 MB 794.3 kB/s eta 0:00:01
     ------------------------------- -------- 2.3/3.0 MB 796.1 kB/s eta 0:00:01
     -------------------------------- ------- 2.4/3.0 MB 800.2 kB/s eta 0:00:01
     --------------------------------- ------ 2.5/3.0 MB 811.5 kB/s eta 0:00:01
     --------------------------------- ------ 2.5/3.0 MB 815.7 kB/s eta 0:00:01
     ---------------------------------- ----- 2.5/3.0 MB 824.8 kB/s eta 0:00:01
     ----------------------------------- ---- 2.6/3.0 MB 820.6 kB/s eta 0:00:01
     ----------------------------------- ---- 2.6/3.0 MB 820.6 kB/s eta 0:00:01
     ------------------------------------ --- 2.7/3.0 MB 822.4 kB/s eta 0:00:01
     ------------------------------------ --- 2.7/3.0 MB 822.4 kB/s eta 0:00:01
     ------------------------------------- -- 2.8/3.0 MB 823.7 kB/s eta 0:00:01
     -------------------------------------- - 2.8/3.0 MB 837.4 kB/s eta 0:00:01
     -------------------------------------- - 2.8/3.0 MB 837.4 kB/s eta 0:00:01
     -------------------------------------- - 2.8/3.0 MB 837.4 kB/s eta 0:00:01
     ---------------------------------------  2.9/3.0 MB 825.1 kB/s eta 0:00:01
     ---------------------------------------  2.9/3.0 MB 815.4 kB/s eta 0:00:01
     ---------------------------------------  2.9/3.0 MB 810.7 kB/s eta 0:00:01
     ---------------------------------------- 3.0/3.0 MB 808.3 kB/s eta 0:00:00
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Preparing metadata (pyproject.toml): started
  Preparing metadata (pyproject.toml): finished with status 'done'
Requirement already satisfied: beautifulsoup4>=4.11.1 in d:\new folder\lib\site-packages (from yfinance) (4.12.2)
Collecting html5lib>=1.1 (from yfinance)
  Obtaining dependency information for html5lib>=1.1 from https://files.pythonhosted.org/packages/6c/dd/a834df6482147d48e225a49515aabc28974ad5a4ca3215c18a882565b028/html5lib-1.1-py2.py3-none-any.whl.metadata
  Downloading html5lib-1.1-py2.py3-none-any.whl.metadata (16 kB)
Requirement already satisfied: soupsieve>1.2 in d:\new folder\lib\site-packages (from beautifulsoup4>=4.11.1->yfinance) (2.4)
Requirement already satisfied: six>=1.9 in d:\new folder\lib\site-packages (from html5lib>=1.1->yfinance) (1.16.0)
Requirement already satisfied: webencodings in d:\new folder\lib\site-packages (from html5lib>=1.1->yfinance) (0.5.1)
Requirement already satisfied: python-dateutil>=2.8.1 in d:\new folder\lib\site-packages (from pandas>=1.3.0->yfinance) (2.8.2)
Requirement already satisfied: charset-normalizer<4,>=2 in d:\new folder\lib\site-packages (from requests>=2.31->yfinance) (2.0.4)
Requirement already satisfied: idna<4,>=2.5 in d:\new folder\lib\site-packages (from requests>=2.31->yfinance) (3.4)
Requirement already satisfied: urllib3<3,>=1.21.1 in d:\new folder\lib\site-packages (from requests>=2.31->yfinance) (1.26.16)
Requirement already satisfied: certifi>=2017.4.17 in d:\new folder\lib\site-packages (from requests>=2.31->yfinance) (2023.7.22)
Downloading yfinance-0.2.38-py2.py3-none-any.whl (72 kB)
   ---------------------------------------- 0.0/73.0 kB ? eta -:--:--
   ---------------- ----------------------- 30.7/73.0 kB ? eta -:--:--
   ---------------------- ----------------- 41.0/73.0 kB 326.8 kB/s eta 0:00:01
   ---------------------------------------- 73.0/73.0 kB 667.6 kB/s eta 0:00:00
Downloading html5lib-1.1-py2.py3-none-any.whl (112 kB)
   ---------------------------------------- 0.0/112.2 kB ? eta -:--:--
   ---------------------------------------- 0.0/112.2 kB ? eta -:--:--
   ---------------------------------------- 0.0/112.2 kB ? eta -:--:--
   ---------------------------------------- 0.0/112.2 kB ? eta -:--:--
   ---------------------------------------- 0.0/112.2 kB ? eta -:--:--
   ---------- ----------------------------- 30.7/112.2 kB ? eta -:--:--
   ---------- ----------------------------- 30.7/112.2 kB ? eta -:--:--
   --------------------- ----------------- 61.4/112.2 kB 544.7 kB/s eta 0:00:01
   --------------------- ----------------- 61.4/112.2 kB 544.7 kB/s eta 0:00:01
   --------------------- ----------------- 61.4/112.2 kB 544.7 kB/s eta 0:00:01
   --------------------- ----------------- 61.4/112.2 kB 544.7 kB/s eta 0:00:01
   --------------------- ----------------- 61.4/112.2 kB 544.7 kB/s eta 0:00:01
   -------------------------------------- 112.2/112.2 kB 309.8 kB/s eta 0:00:00
Downloading multitasking-0.0.11-py3-none-any.whl (8.5 kB)
Building wheels for collected packages: frozendict, peewee
  Building wheel for frozendict (pyproject.toml): started
  Building wheel for frozendict (pyproject.toml): finished with status 'done'
  Created wheel for frozendict: filename=frozendict-2.4.2-cp311-cp311-win_amd64.whl size=15543 sha256=bcb5641bc62c06c62405716f7cca1055083e5358a47447e23693c0b19ad310f3
  Stored in directory: c:\users\alex\appdata\local\pip\cache\wheels\b6\d6\b5\da9ad65b3c11d2d2f3245b0b2476231dc58a2a91768c5ec755
  Building wheel for peewee (pyproject.toml): started
  Building wheel for peewee (pyproject.toml): finished with status 'done'
  Created wheel for peewee: filename=peewee-3.17.3-py3-none-any.whl size=138453 sha256=423a6f3e2a29535eb323cb3ef72fa611e0404293c5930cf838d1519c2c4828d2
  Stored in directory: c:\users\alex\appdata\local\pip\cache\wheels\3e\3d\30\a54ad8c2307aa653f234a6f651ab12fbc5cfbb3f383145ab6a
Successfully built frozendict peewee
Installing collected packages: peewee, multitasking, html5lib, frozendict, yfinance
Successfully installed frozendict-2.4.2 html5lib-1.1 multitasking-0.0.11 peewee-3.17.3 yfinance-0.2.38
In [6]:
import yfinance as yf

# Define the list of Indian companies and their corresponding stock symbols
indian_companies = {
    "Reliance Industries Ltd.": "RELIANCE.NS",
    "Tata Consultancy Services Ltd.": "TCS.NS",
    "HDFC Bank Ltd.": "HDFCBANK.NS",
    "Hindustan Unilever Ltd.": "HINDUNILVR.NS",
    "Infosys Ltd.": "INFY.NS",
    "ICICI Bank Ltd.": "ICICIBANK.NS",
    "Kotak Mahindra Bank Ltd.": "KOTAKBANK.NS",
    "Housing Development Finance Corporation Ltd.": "HDFC.NS",
    "Bharti Airtel Ltd.": "BHARTIARTL.NS",
    "Axis Bank Ltd.": "AXISBANK.NS"
}

# Initialize an empty dictionary to store data for each company
company_data = {}

# Iterate over each company and download historical data
for company, symbol in indian_companies.items():
    try:
        data = yf.download(symbol, start='2022-01-01', end='2022-12-31')
        company_data[company] = data
        print(f"Downloaded data for {company}")
    except Exception as e:
        print(f"Error downloading data for {company}: {e}")

# Access and display the first few rows of data for each company
for company, data in company_data.items():
    print(f"\nStock data for {company}:")
    print(data.head())
[*********************100%%**********************]  1 of 1 completed
Downloaded data for Reliance Industries Ltd.
[*********************100%%**********************]  1 of 1 completed
Downloaded data for Tata Consultancy Services Ltd.
[*********************100%%**********************]  1 of 1 completed
Downloaded data for HDFC Bank Ltd.
[*********************100%%**********************]  1 of 1 completed
Downloaded data for Hindustan Unilever Ltd.
[*********************100%%**********************]  1 of 1 completed
Downloaded data for Infosys Ltd.
[*********************100%%**********************]  1 of 1 completed
Downloaded data for ICICI Bank Ltd.
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed

1 Failed download:
['HDFC.NS']: Exception('%ticker%: No price data found, symbol may be delisted (1d 2022-01-01 -> 2022-12-31)')
Downloaded data for Kotak Mahindra Bank Ltd.
Downloaded data for Housing Development Finance Corporation Ltd.
[*********************100%%**********************]  1 of 1 completed
Downloaded data for Bharti Airtel Ltd.
[*********************100%%**********************]  1 of 1 completed
Downloaded data for Axis Bank Ltd.

Stock data for Reliance Industries Ltd.:
                   Open         High          Low        Close    Adj Close  \
Date                                                                          
2022-01-03  2182.894287  2222.537109  2181.555908  2218.752686  2203.752197   
2022-01-04  2229.875000  2271.502197  2218.891113  2268.825439  2253.486572   
2022-01-05  2272.425293  2286.270264  2245.612061  2279.439941  2264.029297   
2022-01-06  2262.456787  2265.041260  2223.506104  2230.428711  2215.349365   
2022-01-07  2243.766113  2268.779297  2225.859863  2248.427246  2233.226318   

             Volume  
Date                 
2022-01-03  2710805  
2022-01-04  5423864  
2022-01-05  5821906  
2022-01-06  7223711  
2022-01-07  6556057  

Stock data for Tata Consultancy Services Ltd.:
                   Open         High          Low        Close    Adj Close  \
Date                                                                          
2022-01-03  3750.000000  3830.000000  3745.000000  3817.750000  3628.079102   
2022-01-04  3831.100098  3889.149902  3811.699951  3884.750000  3691.750244   
2022-01-05  3865.000000  3870.000000  3812.399902  3860.949951  3669.132812   
2022-01-06  3812.000000  3835.000000  3772.000000  3807.449951  3618.290527   
2022-01-07  3820.000000  3864.899902  3796.399902  3853.500000  3662.052734   

             Volume  
Date                 
2022-01-03  2346158  
2022-01-04  2488606  
2022-01-05  1733031  
2022-01-06  1810293  
2022-01-07  2460591  

Stock data for HDFC Bank Ltd.:
                   Open         High          Low        Close    Adj Close  \
Date                                                                          
2022-01-03  1485.000000  1523.000000  1480.500000  1519.650024  1485.152466   
2022-01-04  1520.000000  1532.900024  1507.800049  1528.550049  1493.850464   
2022-01-05  1536.800049  1572.000000  1528.099976  1564.849976  1529.326294   
2022-01-06  1543.000000  1554.750000  1530.050049  1539.750000  1504.796265   
2022-01-07  1544.000000  1566.750000  1535.900024  1550.550049  1515.351074   

             Volume  
Date                 
2022-01-03  4534592  
2022-01-04  4428676  
2022-01-05  7166319  
2022-01-06  4814465  
2022-01-07  5589692  

Stock data for Hindustan Unilever Ltd.:
                   Open         High          Low        Close    Adj Close  \
Date                                                                          
2022-01-03  2378.000000  2378.000000  2353.000000  2361.300049  2289.408203   
2022-01-04  2368.949951  2408.100098  2355.350098  2401.250000  2328.141602   
2022-01-05  2403.800049  2420.000000  2392.000000  2415.800049  2342.248779   
2022-01-06  2398.000000  2412.000000  2367.699951  2391.399902  2318.591553   
2022-01-07  2388.000000  2421.899902  2388.000000  2416.149902  2342.587891   

             Volume  
Date                 
2022-01-03   879278  
2022-01-04  1484275  
2022-01-05  1202512  
2022-01-06  1198901  
2022-01-07  1026186  

Stock data for Infosys Ltd.:
                   Open         High          Low        Close    Adj Close  \
Date                                                                          
2022-01-03  1887.750000  1914.050049  1887.750000  1898.449951  1810.171875   
2022-01-04  1898.449951  1906.650024  1878.000000  1899.150024  1810.839355   
2022-01-05  1900.000000  1902.900024  1840.000000  1844.650024  1758.873657   
2022-01-06  1828.000000  1828.000000  1800.000000  1817.800049  1733.272217   
2022-01-07  1815.449951  1836.000000  1806.800049  1814.300049  1729.934814   

             Volume  
Date                 
2022-01-03  3329616  
2022-01-04  3921999  
2022-01-05  6995719  
2022-01-06  6449205  
2022-01-07  4834389  

Stock data for ICICI Bank Ltd.:
                  Open        High         Low       Close   Adj Close  \
Date                                                                     
2022-01-03  743.049988  766.000000  743.000000  764.700012  753.932556   
2022-01-04  767.950012  778.000000  763.599976  772.849976  761.967773   
2022-01-05  773.000000  795.849976  771.200012  788.049988  776.953796   
2022-01-06  775.049988  792.500000  774.000000  785.049988  773.996033   
2022-01-07  792.200012  802.299988  786.250000  793.250000  782.080566   

              Volume  
Date                  
2022-01-03   9653095  
2022-01-04  12114437  
2022-01-05  19741360  
2022-01-06  13018067  
2022-01-07  12250210  

Stock data for Kotak Mahindra Bank Ltd.:
                   Open         High          Low        Close    Adj Close  \
Date                                                                          
2022-01-03  1797.000000  1828.099976  1791.599976  1824.449951  1821.852173   
2022-01-04  1830.000000  1857.000000  1815.300049  1852.599976  1849.962036   
2022-01-05  1857.000000  1928.349976  1840.099976  1922.150024  1919.413086   
2022-01-06  1907.099976  1915.000000  1875.000000  1891.900024  1889.206177   
2022-01-07  1891.900024  1925.400024  1883.599976  1904.250000  1901.538696   

             Volume  
Date                 
2022-01-03  1985109  
2022-01-04  2635575  
2022-01-05  4208167  
2022-01-06  2258030  
2022-01-07  2303351  

Stock data for Housing Development Finance Corporation Ltd.:
Empty DataFrame
Columns: [Open, High, Low, Close, Adj Close, Volume]
Index: []

Stock data for Bharti Airtel Ltd.:
                  Open        High         Low       Close   Adj Close  \
Date                                                                     
2022-01-03  687.799988  692.599976  683.099976  691.299988  685.093933   
2022-01-04  692.250000  703.250000  690.400024  697.450012  691.188782   
2022-01-05  700.900024  702.750000  691.750000  700.000000  693.715881   
2022-01-06  702.000000  720.500000  700.000000  710.400024  704.022522   
2022-01-07  713.900024  715.150024  701.450012  704.700012  698.373718   

              Volume  
Date                  
2022-01-03   2939833  
2022-01-04   6473875  
2022-01-05   4586105  
2022-01-06  21642414  
2022-01-07   4315015  

Stock data for Axis Bank Ltd.:
                  Open        High         Low       Close   Adj Close  \
Date                                                                     
2022-01-03  680.250000  698.500000  679.000000  696.349976  694.582825   
2022-01-04  701.000000  711.049988  700.049988  709.150024  707.350403   
2022-01-05  711.900024  730.900024  707.750000  726.900024  725.055359   
2022-01-06  719.950012  733.500000  719.000000  730.299988  728.446716   
2022-01-07  734.000000  740.900024  725.250000  730.599976  728.745911   

              Volume  
Date                  
2022-01-03   8550860  
2022-01-04   9705906  
2022-01-05  11312955  
2022-01-06   7955578  
2022-01-07  10454143  

In [7]:
# Iterate over each company and write data to CSV file in the specified directory
for company, data in company_data.items():
    csv_file_path = f"C:/Users/Alex/{company.replace(' ', '_').replace('.', '_')}_stock_data.csv"  # Absolute path to the CSV file
    data.to_csv(csv_file_path)  # Write data to CSV file
    print(f"Stock data for {company} saved to: {csv_file_path}")
Stock data for Reliance Industries Ltd. saved to: C:/Users/Alex/Reliance_Industries_Ltd__stock_data.csv
Stock data for Tata Consultancy Services Ltd. saved to: C:/Users/Alex/Tata_Consultancy_Services_Ltd__stock_data.csv
Stock data for HDFC Bank Ltd. saved to: C:/Users/Alex/HDFC_Bank_Ltd__stock_data.csv
Stock data for Hindustan Unilever Ltd. saved to: C:/Users/Alex/Hindustan_Unilever_Ltd__stock_data.csv
Stock data for Infosys Ltd. saved to: C:/Users/Alex/Infosys_Ltd__stock_data.csv
Stock data for ICICI Bank Ltd. saved to: C:/Users/Alex/ICICI_Bank_Ltd__stock_data.csv
Stock data for Kotak Mahindra Bank Ltd. saved to: C:/Users/Alex/Kotak_Mahindra_Bank_Ltd__stock_data.csv
Stock data for Housing Development Finance Corporation Ltd. saved to: C:/Users/Alex/Housing_Development_Finance_Corporation_Ltd__stock_data.csv
Stock data for Bharti Airtel Ltd. saved to: C:/Users/Alex/Bharti_Airtel_Ltd__stock_data.csv
Stock data for Axis Bank Ltd. saved to: C:/Users/Alex/Axis_Bank_Ltd__stock_data.csv
In [14]:
# Iterate over each company and write data to CSV file in the specified directory
for company, data in company_data.items():
    csv_file_path = f"C:/Users/Alex/Downloads/{company.replace(' ', '_').replace('.', '_')}_stock_data.csv" # Absolute path to the CSV file
    data.to_csv(csv_file_path)  # Write data to CSV file
    print(f"Stock data for {company} saved to: {csv_file_path}")
Stock data for Reliance Industries Ltd. saved to: C:/Users/Alex/Downloads/Reliance_Industries_Ltd__stock_data.csv
Stock data for Tata Consultancy Services Ltd. saved to: C:/Users/Alex/Downloads/Tata_Consultancy_Services_Ltd__stock_data.csv
Stock data for HDFC Bank Ltd. saved to: C:/Users/Alex/Downloads/HDFC_Bank_Ltd__stock_data.csv
Stock data for Hindustan Unilever Ltd. saved to: C:/Users/Alex/Downloads/Hindustan_Unilever_Ltd__stock_data.csv
Stock data for Infosys Ltd. saved to: C:/Users/Alex/Downloads/Infosys_Ltd__stock_data.csv
Stock data for ICICI Bank Ltd. saved to: C:/Users/Alex/Downloads/ICICI_Bank_Ltd__stock_data.csv
Stock data for Kotak Mahindra Bank Ltd. saved to: C:/Users/Alex/Downloads/Kotak_Mahindra_Bank_Ltd__stock_data.csv
Stock data for Housing Development Finance Corporation Ltd. saved to: C:/Users/Alex/Downloads/Housing_Development_Finance_Corporation_Ltd__stock_data.csv
Stock data for Bharti Airtel Ltd. saved to: C:/Users/Alex/Downloads/Bharti_Airtel_Ltd__stock_data.csv
Stock data for Axis Bank Ltd. saved to: C:/Users/Alex/Downloads/Axis_Bank_Ltd__stock_data.csv
In [15]:
import yfinance as yf

# Define the list of Indian companies and their corresponding stock symbols
indian_companies = {
    "Reliance Industries Ltd.": "RELIANCE.NS",
    "Tata Consultancy Services Ltd.": "TCS.NS",
    "HDFC Bank Ltd.": "HDFCBANK.NS",
    "Hindustan Unilever Ltd.": "HINDUNILVR.NS",
    "Infosys Ltd.": "INFY.NS",
    "ICICI Bank Ltd.": "ICICIBANK.NS",
    "Kotak Mahindra Bank Ltd.": "KOTAKBANK.NS",
    "Housing Development Finance Corporation Ltd.": "HDFC.NS",
    "Bharti Airtel Ltd.": "BHARTIARTL.NS",
    "Axis Bank Ltd.": "AXISBANK.NS"
}

# Initialize an empty dictionary to store data for each company
company_data = {}

# Define start and end dates for past 5 years
start_date = '2017-04-21'
end_date = '2022-04-21'  # Assuming today's date is 2022-04-21

# Iterate over each company and download historical data for the past 5 years
for company, symbol in indian_companies.items():
    try:
        data = yf.download(symbol, start=start_date, end=end_date)
        company_data[company] = data
        print(f"Downloaded data for {company}")
    except Exception as e:
        print(f"Error downloading data for {company}: {e}")

# Access and display the first few rows of data for each company
for company, data in company_data.items():
    print(f"\nStock data for {company}:")
    print(data.head())
[*********************100%%**********************]  1 of 1 completed
Downloaded data for Reliance Industries Ltd.
[*********************100%%**********************]  1 of 1 completed
Downloaded data for Tata Consultancy Services Ltd.
[*********************100%%**********************]  1 of 1 completed
Downloaded data for HDFC Bank Ltd.
[*********************100%%**********************]  1 of 1 completed
Downloaded data for Hindustan Unilever Ltd.
[*********************100%%**********************]  1 of 1 completed
Downloaded data for Infosys Ltd.
[*********************100%%**********************]  1 of 1 completed
Downloaded data for ICICI Bank Ltd.
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed

1 Failed download:
['HDFC.NS']: Exception('%ticker%: No price data found, symbol may be delisted (1d 2017-04-21 -> 2022-04-21)')
Downloaded data for Kotak Mahindra Bank Ltd.
Downloaded data for Housing Development Finance Corporation Ltd.
[*********************100%%**********************]  1 of 1 completed
Downloaded data for Bharti Airtel Ltd.
[*********************100%%**********************]  1 of 1 completed
Downloaded data for Axis Bank Ltd.

Stock data for Reliance Industries Ltd.:
                  Open        High         Low       Close   Adj Close  \
Date                                                                     
2017-04-21  631.118164  649.633423  630.226685  641.175842  619.190918   
2017-04-24  644.170227  656.033752  640.124329  647.987610  625.769104   
2017-04-25  667.462891  671.005920  651.964966  655.027954  632.568054   
2017-04-26  656.033752  658.342407  641.221558  647.553284  625.349731   
2017-04-27  647.804749  651.073486  641.038696  644.375977  622.281433   

              Volume  
Date                  
2017-04-21  15115453  
2017-04-24  12756255  
2017-04-25  18382157  
2017-04-26   8381576  
2017-04-27   6285797  

Stock data for Tata Consultancy Services Ltd.:
                   Open         High          Low        Close    Adj Close  \
Date                                                                          
2017-04-21  1164.550049  1167.824951  1150.500000  1155.400024   999.935486   
2017-04-24  1150.000000  1169.824951  1141.250000  1164.050049  1007.422058   
2017-04-25  1164.000000  1172.224976  1151.349976  1155.750000  1000.238586   
2017-04-26  1170.000000  1171.974976  1151.525024  1155.175049   999.741211   
2017-04-27  1153.025024  1163.900024  1138.824951  1151.324951   996.408813   

             Volume  
Date                 
2017-04-21  1161154  
2017-04-24  2000020  
2017-04-25  3148710  
2017-04-26  2187438  
2017-04-27  5773186  

Stock data for HDFC Bank Ltd.:
                  Open        High         Low       Close   Adj Close  \
Date                                                                     
2017-04-21  733.000000  749.500000  726.650024  748.299988  712.738159   
2017-04-24  749.049988  769.500000  748.500000  766.525024  730.097046   
2017-04-25  767.525024  772.750000  764.799988  768.525024  732.001892   
2017-04-26  771.474976  776.500000  734.224976  775.325012  738.478760   
2017-04-27  773.049988  786.974976  773.049988  784.299988  747.027222   

              Volume  
Date                  
2017-04-21   8629016  
2017-04-24  10103476  
2017-04-25   4528890  
2017-04-26   3897926  
2017-04-27   8090210  

Stock data for Hindustan Unilever Ltd.:
                  Open        High         Low       Close   Adj Close  \
Date                                                                     
2017-04-21  919.500000  923.900024  903.500000  906.400024  817.854309   
2017-04-24  909.900024  909.900024  898.549988  904.549988  816.185059   
2017-04-25  907.000000  927.000000  903.049988  924.000000  833.735046   
2017-04-26  924.000000  945.000000  920.299988  941.349976  849.389954   
2017-04-27  941.099976  951.000000  936.200012  947.299988  854.758911   

             Volume  
Date                 
2017-04-21   761841  
2017-04-24   789135  
2017-04-25  1105317  
2017-04-26  1296199  
2017-04-27  1096343  

Stock data for Infosys Ltd.:
                  Open        High         Low       Close   Adj Close  \
Date                                                                     
2017-04-21  467.399994  467.399994  460.549988  461.850006  389.187134   
2017-04-24  458.750000  464.250000  456.500000  463.274994  390.387970   
2017-04-25  462.950012  466.500000  460.274994  464.674988  391.567688   
2017-04-26  464.975006  467.774994  455.100006  457.125000  385.205505   
2017-04-27  458.000000  464.500000  458.000000  462.625000  389.840179   

             Volume  
Date                 
2017-04-21  3577466  
2017-04-24  5556666  
2017-04-25  4737060  
2017-04-26  9084496  
2017-04-27  7797208  

Stock data for ICICI Bank Ltd.:
                  Open        High         Low       Close   Adj Close  \
Date                                                                     
2017-04-21  247.863632  248.909088  242.727264  244.681824  237.015900   
2017-04-24  245.272720  246.681824  241.090912  244.227264  236.575607   
2017-04-25  247.272720  248.454544  245.454544  247.727264  239.965927   
2017-04-26  249.090912  252.681824  248.181824  251.727264  243.840607   
2017-04-27  251.772720  251.863632  248.500000  249.227264  241.418945   

              Volume  
Date                  
2017-04-21  18165879  
2017-04-24  24418208  
2017-04-25  13685114  
2017-04-26  15205419  
2017-04-27  14909618  

Stock data for Kotak Mahindra Bank Ltd.:
                  Open        High         Low       Close   Adj Close  \
Date                                                                     
2017-04-21  890.000000  897.500000  878.500000  880.400024  877.239380   
2017-04-24  878.000000  898.450012  876.299988  895.750000  892.534241   
2017-04-25  899.000000  904.000000  885.099976  898.000000  894.776062   
2017-04-26  899.700012  921.000000  895.549988  900.349976  897.117676   
2017-04-27  907.950012  919.349976  890.000000  916.650024  913.359253   

             Volume  
Date                 
2017-04-21  1260745  
2017-04-24  3128325  
2017-04-25  2496583  
2017-04-26  3611321  
2017-04-27  7060437  

Stock data for Housing Development Finance Corporation Ltd.:
Empty DataFrame
Columns: [Open, High, Low, Close, Adj Close, Volume]
Index: []

Stock data for Bharti Airtel Ltd.:
                  Open        High         Low       Close   Adj Close  \
Date                                                                     
2017-04-21  308.229980  311.835022  306.697845  308.950989  297.900024   
2017-04-24  310.032501  312.240570  305.210785  310.618317  299.507660   
2017-04-25  309.131256  324.272369  307.689240  319.000000  307.589508   
2017-04-26  319.000000  324.452606  317.242554  322.244537  310.718048   
2017-04-27  319.270386  326.210052  318.819763  322.559967  311.022156   

             Volume  
Date                 
2017-04-21  1500170  
2017-04-24  1487606  
2017-04-25  4747068  
2017-04-26  3272330  
2017-04-27  4978376  

Stock data for Axis Bank Ltd.:
                  Open        High         Low       Close   Adj Close  \
Date                                                                     
2017-04-21  492.000000  497.000000  483.299988  486.250000  479.701324   
2017-04-24  487.950012  503.600006  481.000000  498.649994  491.934326   
2017-04-25  501.000000  520.150024  495.100006  516.400024  509.445282   
2017-04-26  519.500000  525.000000  508.049988  517.150024  510.185181   
2017-04-27  524.000000  524.000000  503.250000  506.600006  499.777252   

              Volume  
Date                  
2017-04-21  10301245  
2017-04-24  14182302  
2017-04-25  13778124  
2017-04-26  11516903  
2017-04-27  22108735  

In [16]:
import yfinance as yf
import pandas as pd

# Define the list of Indian companies and their corresponding stock symbols
indian_companies = {
    "Reliance Industries Ltd.": "RELIANCE.NS",
    "Tata Consultancy Services Ltd.": "TCS.NS",
    "HDFC Bank Ltd.": "HDFCBANK.NS",
    "Hindustan Unilever Ltd.": "HINDUNILVR.NS",
    "Infosys Ltd.": "INFY.NS",
    "ICICI Bank Ltd.": "ICICIBANK.NS",
    "Kotak Mahindra Bank Ltd.": "KOTAKBANK.NS",
    "Housing Development Finance Corporation Ltd.": "HDFC.NS",
    "Bharti Airtel Ltd.": "BHARTIARTL.NS",
    "Axis Bank Ltd.": "AXISBANK.NS"
}

# Initialize an empty dictionary to store data for each company
company_data = {}

# Define start and end dates for past 5 years
start_date = '2017-04-21'
end_date = '2022-04-21'  # Assuming today's date is 2022-04-21

# Iterate over each company and download historical data for the past 5 years
for company, symbol in indian_companies.items():
    try:
        data = yf.download(symbol, start=start_date, end=end_date)
        company_data[company] = data
        print(f"Downloaded data for {company}")
    except Exception as e:
        print(f"Error downloading data for {company}: {e}")

# Convert data to CSV and download
for company, data in company_data.items():
    csv_file_path = f"{company.replace(' ', '_').replace('.', '_')}_stock_data.csv"  # Create CSV file name based on company name
    data.to_csv(csv_file_path)  # Convert data to CSV and save
    print(f"Stock data for {company} saved to: {csv_file_path}")

# Zip CSV files and download
import shutil
import os

zip_file_path = "indian_stock_data.zip"  # Define zip file name
with shutil.ZipFile(zip_file_path, 'w') as zip_file:
    for file in os.listdir("."):
        if file.endswith(".csv"):
            zip_file.write(file)

# Remove CSV files after zipping
for file in os.listdir("."):
    if file.endswith(".csv"):
        os.remove(file)

# Provide link to download the zip file
print(f"Stock data for all companies zipped and saved to: {zip_file_path}")
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed
Downloaded data for Reliance Industries Ltd.
Downloaded data for Tata Consultancy Services Ltd.
Downloaded data for HDFC Bank Ltd.
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed
Downloaded data for Hindustan Unilever Ltd.
Downloaded data for Infosys Ltd.
Downloaded data for ICICI Bank Ltd.
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed

1 Failed download:
['HDFC.NS']: Exception('%ticker%: No price data found, symbol may be delisted (1d 2017-04-21 -> 2022-04-21)')
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed
Downloaded data for Kotak Mahindra Bank Ltd.
Downloaded data for Housing Development Finance Corporation Ltd.
Downloaded data for Bharti Airtel Ltd.
Downloaded data for Axis Bank Ltd.
Stock data for Reliance Industries Ltd. saved to: Reliance_Industries_Ltd__stock_data.csv
Stock data for Tata Consultancy Services Ltd. saved to: Tata_Consultancy_Services_Ltd__stock_data.csv
Stock data for HDFC Bank Ltd. saved to: HDFC_Bank_Ltd__stock_data.csv
Stock data for Hindustan Unilever Ltd. saved to: Hindustan_Unilever_Ltd__stock_data.csv
Stock data for Infosys Ltd. saved to: Infosys_Ltd__stock_data.csv
Stock data for ICICI Bank Ltd. saved to: ICICI_Bank_Ltd__stock_data.csv
Stock data for Kotak Mahindra Bank Ltd. saved to: Kotak_Mahindra_Bank_Ltd__stock_data.csv
Stock data for Housing Development Finance Corporation Ltd. saved to: Housing_Development_Finance_Corporation_Ltd__stock_data.csv
Stock data for Bharti Airtel Ltd. saved to: Bharti_Airtel_Ltd__stock_data.csv
Stock data for Axis Bank Ltd. saved to: Axis_Bank_Ltd__stock_data.csv
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[16], line 45
     42 import os
     44 zip_file_path = "indian_stock_data.zip"  # Define zip file name
---> 45 with shutil.ZipFile(zip_file_path, 'w') as zip_file:
     46     for file in os.listdir("."):
     47         if file.endswith(".csv"):

AttributeError: module 'shutil' has no attribute 'ZipFile'
In [17]:
import os
import zipfile

# Define the directory containing the CSV files
csv_dir = r"C:\Users\Alex\Downloads"

# Define the zip file path
zip_file_path = r"C:\Users\Alex\Downloads\indian_stock_data.zip"

# Create a zip file containing all CSV files in the directory
with zipfile.ZipFile(zip_file_path, 'w') as zip_file:
    for file_name in os.listdir(csv_dir):
        if file_name.endswith(".csv"):
            file_path = os.path.join(csv_dir, file_name)
            zip_file.write(file_path, arcname=file_name)

print("Zip file created successfully.")
Zip file created successfully.
In [18]:
import yfinance as yf
import pandas as pd

# Define the list of Indian companies and their corresponding stock symbols
indian_companies = {
    "Reliance Industries Ltd.": "RELIANCE.NS",
    "Tata Consultancy Services Ltd.": "TCS.NS",
    "HDFC Bank Ltd.": "HDFCBANK.NS",
    "Hindustan Unilever Ltd.": "HINDUNILVR.NS",
    "Infosys Ltd.": "INFY.NS",
    "ICICI Bank Ltd.": "ICICIBANK.NS",
    "Kotak Mahindra Bank Ltd.": "KOTAKBANK.NS",
    "Housing Development Finance Corporation Ltd.": "HDFC.NS",
    "Bharti Airtel Ltd.": "BHARTIARTL.NS",
    "Axis Bank Ltd.": "AXISBANK.NS"
}

# Initialize an empty dictionary to store data for each company
company_data = {}

# Define start and end dates for past 5 years
start_date = '2017-04-21'
end_date = '2022-04-21'  # Assuming today's date is 2022-04-21

# Iterate over each company and download historical data for the past 5 years
for company, symbol in indian_companies.items():
    try:
        data = yf.download(symbol, start=start_date, end=end_date)
        company_data[company] = data
        print(f"Downloaded data for {company}")
    except Exception as e:
        print(f"Error downloading data for {company}: {e}")

# Convert data to CSV and download
for company, data in company_data.items():
    csv_file_path = f"{company.replace(' ', '_').replace('.', '_')}_stock_data.csv"  # Create CSV file name based on company name
    data.to_csv(csv_file_path)  # Convert data to CSV and save
    print(f"Stock data for {company} saved to: {csv_file_path}")

# Zip CSV files and download
import shutil
import os

zip_file_path = "indian_stock_data.zip"  # Define zip file name
with shutil.ZipFile(zip_file_path, 'w') as zip_file:
    for file in os.listdir("."):
        if file.endswith(".csv"):
            zip_file.write(file)

# Remove CSV files after zipping
for file in os.listdir("."):
    if file.endswith(".csv"):
        os.remove(file)

# Provide link to download the zip file
print(f"Stock data for all companies zipped and saved to: {zip_file_path}")
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed
Downloaded data for Reliance Industries Ltd.
Downloaded data for Tata Consultancy Services Ltd.
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed
Downloaded data for HDFC Bank Ltd.
Downloaded data for Hindustan Unilever Ltd.
Downloaded data for Infosys Ltd.
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed

1 Failed download:
['HDFC.NS']: Exception('%ticker%: No price data found, symbol may be delisted (1d 2017-04-21 -> 2022-04-21)')
[*********************100%%**********************]  1 of 1 completed
Downloaded data for ICICI Bank Ltd.
Downloaded data for Kotak Mahindra Bank Ltd.
Downloaded data for Housing Development Finance Corporation Ltd.
[*********************100%%**********************]  1 of 1 completed
Downloaded data for Bharti Airtel Ltd.
Downloaded data for Axis Bank Ltd.
Stock data for Reliance Industries Ltd. saved to: Reliance_Industries_Ltd__stock_data.csv
Stock data for Tata Consultancy Services Ltd. saved to: Tata_Consultancy_Services_Ltd__stock_data.csv
Stock data for HDFC Bank Ltd. saved to: HDFC_Bank_Ltd__stock_data.csv
Stock data for Hindustan Unilever Ltd. saved to: Hindustan_Unilever_Ltd__stock_data.csv
Stock data for Infosys Ltd. saved to: Infosys_Ltd__stock_data.csv
Stock data for ICICI Bank Ltd. saved to: ICICI_Bank_Ltd__stock_data.csv
Stock data for Kotak Mahindra Bank Ltd. saved to: Kotak_Mahindra_Bank_Ltd__stock_data.csv
Stock data for Housing Development Finance Corporation Ltd. saved to: Housing_Development_Finance_Corporation_Ltd__stock_data.csv
Stock data for Bharti Airtel Ltd. saved to: Bharti_Airtel_Ltd__stock_data.csv
Stock data for Axis Bank Ltd. saved to: Axis_Bank_Ltd__stock_data.csv
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[18], line 45
     42 import os
     44 zip_file_path = "indian_stock_data.zip"  # Define zip file name
---> 45 with shutil.ZipFile(zip_file_path, 'w') as zip_file:
     46     for file in os.listdir("."):
     47         if file.endswith(".csv"):

AttributeError: module 'shutil' has no attribute 'ZipFile'
In [19]:
import yfinance as yf
import pandas as pd
import zipfile
import os

# Define the list of Indian companies and their corresponding stock symbols
indian_companies = {
    "Reliance Industries Ltd.": "RELIANCE.NS",
    "Tata Consultancy Services Ltd.": "TCS.NS",
    "HDFC Bank Ltd.": "HDFCBANK.NS",
    "Hindustan Unilever Ltd.": "HINDUNILVR.NS",
    "Infosys Ltd.": "INFY.NS",
    "ICICI Bank Ltd.": "ICICIBANK.NS",
    "Kotak Mahindra Bank Ltd.": "KOTAKBANK.NS",
    "Housing Development Finance Corporation Ltd.": "HDFC.NS",
    "Bharti Airtel Ltd.": "BHARTIARTL.NS",
    "Axis Bank Ltd.": "AXISBANK.NS"
}

# Initialize an empty dictionary to store data for each company
company_data = {}

# Define start and end dates for past 5 years
start_date = '2017-04-21'
end_date = '2022-04-21'  # Assuming today's date is 2022-04-21

# Iterate over each company and download historical data for the past 5 years
for company, symbol in indian_companies.items():
    try:
        data = yf.download(symbol, start=start_date, end=end_date)
        company_data[company] = data
        print(f"Downloaded data for {company}")
    except Exception as e:
        print(f"Error downloading data for {company}: {e}")

# Convert data to CSV and download
for company, data in company_data.items():
    csv_file_path = f"{company.replace(' ', '_').replace('.', '_')}_stock_data.csv"  # Create CSV file name based on company name
    data.to_csv(csv_file_path)  # Convert data to CSV and save
    print(f"Stock data for {company} saved to: {csv_file_path}")

# Zip CSV files and download
zip_file_path = "indian_stock_data.zip"  # Define zip file name
with zipfile.ZipFile(zip_file_path, 'w') as zip_file:
    for file in os.listdir("."):
        if file.endswith(".csv"):
            zip_file.write(file)

# Remove CSV files after zipping
for file in os.listdir("."):
    if file.endswith(".csv"):
        os.remove(file)

# Provide link to download the zip file
print(f"Stock data for all companies zipped and saved to: {zip_file_path}")
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed
Downloaded data for Reliance Industries Ltd.
Downloaded data for Tata Consultancy Services Ltd.
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed
Downloaded data for HDFC Bank Ltd.
Downloaded data for Hindustan Unilever Ltd.
Downloaded data for Infosys Ltd.
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed

1 Failed download:
['HDFC.NS']: Exception('%ticker%: No price data found, symbol may be delisted (1d 2017-04-21 -> 2022-04-21)')
[*********************100%%**********************]  1 of 1 completed
Downloaded data for ICICI Bank Ltd.
Downloaded data for Kotak Mahindra Bank Ltd.
Downloaded data for Housing Development Finance Corporation Ltd.
[*********************100%%**********************]  1 of 1 completed
Downloaded data for Bharti Airtel Ltd.
Downloaded data for Axis Bank Ltd.
Stock data for Reliance Industries Ltd. saved to: Reliance_Industries_Ltd__stock_data.csv
Stock data for Tata Consultancy Services Ltd. saved to: Tata_Consultancy_Services_Ltd__stock_data.csv
Stock data for HDFC Bank Ltd. saved to: HDFC_Bank_Ltd__stock_data.csv
Stock data for Hindustan Unilever Ltd. saved to: Hindustan_Unilever_Ltd__stock_data.csv
Stock data for Infosys Ltd. saved to: Infosys_Ltd__stock_data.csv
Stock data for ICICI Bank Ltd. saved to: ICICI_Bank_Ltd__stock_data.csv
Stock data for Kotak Mahindra Bank Ltd. saved to: Kotak_Mahindra_Bank_Ltd__stock_data.csv
Stock data for Housing Development Finance Corporation Ltd. saved to: Housing_Development_Finance_Corporation_Ltd__stock_data.csv
Stock data for Bharti Airtel Ltd. saved to: Bharti_Airtel_Ltd__stock_data.csv
Stock data for Axis Bank Ltd. saved to: Axis_Bank_Ltd__stock_data.csv
Stock data for all companies zipped and saved to: indian_stock_data.zip
In [21]:
import yfinance as yf
import pandas as pd
import zipfile
import os

# Define the list of Indian companies and their corresponding stock symbols
indian_companies = {
    "Reliance Industries Ltd.": "RELIANCE.NS",
    "Tata Consultancy Services Ltd.": "TCS.NS",
    "HDFC Bank Ltd.": "HDFCBANK.NS",
    "Hindustan Unilever Ltd.": "HINDUNILVR.NS",
    "Infosys Ltd.": "INFY.NS",
    "ICICI Bank Ltd.": "ICICIBANK.NS",
    "Kotak Mahindra Bank Ltd.": "KOTAKBANK.NS",
    "Housing Development Finance Corporation Ltd.": "HDFC.NS",
    "Bharti Airtel Ltd.": "BHARTIARTL.NS",
    "Axis Bank Ltd.": "AXISBANK.NS"
}

# Initialize an empty dictionary to store data for each company
company_data = {}

# Define start and end dates for past 10 years
end_date = '2024-04-21'  # Assuming today's date is 2022-04-21
start_date = pd.to_datetime(end_date) - pd.DateOffset(years=10)

# Iterate over each company and download historical data for the past 10 years
for company, symbol in indian_companies.items():
    try:
        data = yf.download(symbol, start=start_date, end=end_date)
        company_data[company] = data
        print(f"Downloaded data for {company}")
    except Exception as e:
        print(f"Error downloading data for {company}: {e}")

# Convert data to CSV and download
for company, data in company_data.items():
    csv_file_path = f"{company.replace(' ', '_').replace('.', '_')}_stock_data.csv"  # Create CSV file name based on company name
    data.to_csv(csv_file_path)  # Convert data to CSV and save
    print(f"Stock data for {company} saved to: {csv_file_path}")

# Zip CSV files and download
zip_file_path = "indian_stock_data.zip"  # Define zip file name
with zipfile.ZipFile(zip_file_path, 'w') as zip_file:
    for file in os.listdir("."):
        if file.endswith(".csv"):
            zip_file.write(file)

# Remove CSV files after zipping
for file in os.listdir("."):
    if file.endswith(".csv"):
        os.remove(file)

# Provide link to download the zip file
print(f"Stock data for all companies zipped and saved to: {zip_file_path}")
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed
Downloaded data for Reliance Industries Ltd.
Downloaded data for Tata Consultancy Services Ltd.
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed
Downloaded data for HDFC Bank Ltd.
Downloaded data for Hindustan Unilever Ltd.
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed
Downloaded data for Infosys Ltd.
Downloaded data for ICICI Bank Ltd.
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed

1 Failed download:
['HDFC.NS']: Exception('%ticker%: No price data found, symbol may be delisted (1d 2014-04-21 00:00:00 -> 2024-04-21)')
[*********************100%%**********************]  1 of 1 completed
Downloaded data for Kotak Mahindra Bank Ltd.
Downloaded data for Housing Development Finance Corporation Ltd.
Downloaded data for Bharti Airtel Ltd.
[*********************100%%**********************]  1 of 1 completed
Downloaded data for Axis Bank Ltd.
Stock data for Reliance Industries Ltd. saved to: Reliance_Industries_Ltd__stock_data.csv
Stock data for Tata Consultancy Services Ltd. saved to: Tata_Consultancy_Services_Ltd__stock_data.csv
Stock data for HDFC Bank Ltd. saved to: HDFC_Bank_Ltd__stock_data.csv
Stock data for Hindustan Unilever Ltd. saved to: Hindustan_Unilever_Ltd__stock_data.csv
Stock data for Infosys Ltd. saved to: Infosys_Ltd__stock_data.csv
Stock data for ICICI Bank Ltd. saved to: ICICI_Bank_Ltd__stock_data.csv
Stock data for Kotak Mahindra Bank Ltd. saved to: Kotak_Mahindra_Bank_Ltd__stock_data.csv
Stock data for Housing Development Finance Corporation Ltd. saved to: Housing_Development_Finance_Corporation_Ltd__stock_data.csv
Stock data for Bharti Airtel Ltd. saved to: Bharti_Airtel_Ltd__stock_data.csv
Stock data for Axis Bank Ltd. saved to: Axis_Bank_Ltd__stock_data.csv
Stock data for all companies zipped and saved to: indian_stock_data.zip
In [26]:
import yfinance as yf
import pandas as pd
import zipfile
import os

# Define the list of Indian companies and their corresponding stock symbols
indian_companies = {
    "Reliance Industries Ltd.": "RELIANCE.NS",
    "Tata Consultancy Services Ltd.": "TCS.NS",
    "HDFC Bank Ltd.": "HDFCBANK.NS",
    "Hindustan Unilever Ltd.": "HINDUNILVR.NS",
    "Infosys Ltd.": "INFY.NS",
    "ICICI Bank Ltd.": "ICICIBANK.NS",
    "Kotak Mahindra Bank Ltd.": "KOTAKBANK.NS",
    "Housing Development Finance Corporation Ltd.": "HDFC.NS",
    "Bharti Airtel Ltd.": "BHARTIARTL.NS",
    "Axis Bank Ltd.": "AXISBANK.NS"
}

# Initialize an empty dictionary to store data for each company
company_data = {}

# Define start and end dates for past 10 years
end_date = '2022-04-21'  # Assuming today's date is 2022-04-21
start_date = pd.to_datetime(end_date) - pd.DateOffset(years=10)

# Iterate over each company and download historical data for the past 10 years
for company, symbol in indian_companies.items():
    try:
        data = yf.download(symbol, start=start_date, end=end_date)
        company_data[company] = data
        print(f"Downloaded data for {company}")
    except Exception as e:
        print(f"Error downloading data for {company}: {e}")

# Convert data to CSV and download
for company, data in company_data.items():
    csv_file_path = f"{company.replace(' ', '_').replace('.', '_')}_stock_data.csv"  # Create CSV file name based on company name
    data.to_csv(csv_file_path)  # Convert data to CSV and save
    print(f"Stock data for {company} saved to: {csv_file_path}")

# Zip CSV files and download
zip_file_path = "indian_stock_data2.zip"  # Define zip file name
with zipfile.ZipFile(zip_file_path, 'w') as zip_file:
    for file in os.listdir("."):
        if file.endswith(".csv"):
            zip_file.write(file)

# Remove CSV files after zipping
for file in os.listdir("."):
    if file.endswith(".csv"):
        os.remove(file)

# Provide link to download the zip file
print(f"Stock data for all companies zipped and saved to: {zip_file_path}")
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed
Downloaded data for Reliance Industries Ltd.
Downloaded data for Tata Consultancy Services Ltd.
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed
Downloaded data for HDFC Bank Ltd.
Downloaded data for Hindustan Unilever Ltd.
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed
Downloaded data for Infosys Ltd.
Downloaded data for ICICI Bank Ltd.
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed

1 Failed download:
['HDFC.NS']: Exception('%ticker%: No price data found, symbol may be delisted (1d 2012-04-21 00:00:00 -> 2022-04-21)')
[*********************100%%**********************]  1 of 1 completed
Downloaded data for Kotak Mahindra Bank Ltd.
Downloaded data for Housing Development Finance Corporation Ltd.
Downloaded data for Bharti Airtel Ltd.
[*********************100%%**********************]  1 of 1 completed
Downloaded data for Axis Bank Ltd.
Stock data for Reliance Industries Ltd. saved to: Reliance_Industries_Ltd__stock_data.csv
Stock data for Tata Consultancy Services Ltd. saved to: Tata_Consultancy_Services_Ltd__stock_data.csv
Stock data for HDFC Bank Ltd. saved to: HDFC_Bank_Ltd__stock_data.csv
Stock data for Hindustan Unilever Ltd. saved to: Hindustan_Unilever_Ltd__stock_data.csv
Stock data for Infosys Ltd. saved to: Infosys_Ltd__stock_data.csv
Stock data for ICICI Bank Ltd. saved to: ICICI_Bank_Ltd__stock_data.csv
Stock data for Kotak Mahindra Bank Ltd. saved to: Kotak_Mahindra_Bank_Ltd__stock_data.csv
Stock data for Housing Development Finance Corporation Ltd. saved to: Housing_Development_Finance_Corporation_Ltd__stock_data.csv
Stock data for Bharti Airtel Ltd. saved to: Bharti_Airtel_Ltd__stock_data.csv
Stock data for Axis Bank Ltd. saved to: Axis_Bank_Ltd__stock_data.csv
Stock data for all companies zipped and saved to: indian_stock_data2.zip
In [27]:
import yfinance as yf
import pandas as pd
import zipfile
import os

# Define the list of Indian companies and their corresponding stock symbols
indian_companies = {
    "Reliance Industries Ltd.": "RELIANCE.NS",
    "Tata Consultancy Services Ltd.": "TCS.NS",
    "HDFC Bank Ltd.": "HDFCBANK.NS",
    "Hindustan Unilever Ltd.": "HINDUNILVR.NS",
    "Infosys Ltd.": "INFY.NS",
    "ICICI Bank Ltd.": "ICICIBANK.NS",
    "Kotak Mahindra Bank Ltd.": "KOTAKBANK.NS",
    "Housing Development Finance Corporation Ltd.": "HDFC.NS",
    "Bharti Airtel Ltd.": "BHARTIARTL.NS",
    "Axis Bank Ltd.": "AXISBANK.NS"
}

# Initialize an empty dictionary to store data for each company
company_data = {}

# Define start and end dates for past 10 years
end_date = '2022-04-21'  # Assuming today's date is 2022-04-21
start_date = pd.to_datetime(end_date) - pd.DateOffset(years=10)

# Iterate over each company and download historical data for the past 10 years
for company, symbol in indian_companies.items():
    try:
        data = yf.download(symbol, start=start_date, end=end_date)
        company_data[company] = data
        print(f"Downloaded data for {company}")
    except Exception as e:
        print(f"Error downloading data for {company}: {e}")

# Convert data to CSV and download
for company, data in company_data.items():
    csv_file_path = f"{company.replace(' ', '_').replace('.', '_')}_stock_data.csv"  # Create CSV file name based on company name
    data.to_\csv(csv_file_path)  # Convert data to CSV and save
    print(f"Stock data for {company} saved to: {csv_file_path}")

# Zip CSV files and save to Downloads folder
zip_file_path = os.path.join(os.path.expanduser("~"), "Downloads", "indian_stock_data2.zip")  # Define zip file path in Downloads folder
with zipfile.ZipFile(zip_file_path, 'w') as zip_file:
    for file in os.listdir("."):
        if file.endswith(".csv"):
            zip_file.write(file)

# Remove CSV files after zipping
for file in os.listdir("."):
    if file.endswith(".csv"):
        os.remove(file)

# Provide link to download the zip file
print(f"Stock data for all companies zipped and saved to: {zip_file_path}")
  Cell In[27], line 39
    data.to_\csv(csv_file_path)  # Convert data to CSV and save
             ^
SyntaxError: unexpected character after line continuation character
In [28]:
import yfinance as yf
import pandas as pd
import zipfile
import os

# Define the list of Indian companies and their corresponding stock symbols
indian_companies = {
    "Reliance Industries Ltd.": "RELIANCE.NS",
    "Tata Consultancy Services Ltd.": "TCS.NS",
    "HDFC Bank Ltd.": "HDFCBANK.NS",
    "Hindustan Unilever Ltd.": "HINDUNILVR.NS",
    "Infosys Ltd.": "INFY.NS",
    "ICICI Bank Ltd.": "ICICIBANK.NS",
    "Kotak Mahindra Bank Ltd.": "KOTAKBANK.NS",
    "Housing Development Finance Corporation Ltd.": "HDFC.NS",
    "Bharti Airtel Ltd.": "BHARTIARTL.NS",
    "Axis Bank Ltd.": "AXISBANK.NS"
}

# Initialize an empty dictionary to store data for each company
company_data = {}

# Define start and end dates for past 10 years
end_date = '2022-04-21'  # Assuming today's date is 2022-04-21
start_date = pd.to_datetime(end_date) - pd.DateOffset(years=10)

# Iterate over each company and download historical data for the past 10 years
for company, symbol in indian_companies.items():
    try:
        data = yf.download(symbol, start=start_date, end=end_date)
        company_data[company] = data
        print(f"Downloaded data for {company}")
    except Exception as e:
        print(f"Error downloading data for {company}: {e}")

# Convert data to CSV and download
for company, data in company_data.items():
    csv_file_path = f"{company.replace(' ', '_').replace('.', '_')}_stock_data.csv"  # Create CSV file name based on company name
    data.to_csv(csv_file_path)  # Convert data to CSV and save
    print(f"Stock data for {company} saved to: {csv_file_path}")

# Zip CSV files and save to Downloads folder
zip_file_path = os.path.join(os.path.expanduser("~"), "Downloads", "indian_stock_data2.zip")  # Define zip file path in Downloads folder
with zipfile.ZipFile(zip_file_path, 'w') as zip_file:
    for file in os.listdir("."):
        if file.endswith(".csv"):
            zip_file.write(file)

# Remove CSV files after zipping
for file in os.listdir("."):
    if file.endswith(".csv"):
        os.remove(file)

# Provide link to download the zip file
print(f"Stock data for all companies zipped and saved to: {zip_file_path}")
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed
Downloaded data for Reliance Industries Ltd.
Downloaded data for Tata Consultancy Services Ltd.
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed
Downloaded data for HDFC Bank Ltd.
Downloaded data for Hindustan Unilever Ltd.
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed
Downloaded data for Infosys Ltd.
Downloaded data for ICICI Bank Ltd.
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed

1 Failed download:
['HDFC.NS']: Exception('%ticker%: No price data found, symbol may be delisted (1d 2012-04-21 00:00:00 -> 2022-04-21)')
[*********************100%%**********************]  1 of 1 completed
Downloaded data for Kotak Mahindra Bank Ltd.
Downloaded data for Housing Development Finance Corporation Ltd.
Downloaded data for Bharti Airtel Ltd.
[*********************100%%**********************]  1 of 1 completed
Downloaded data for Axis Bank Ltd.
Stock data for Reliance Industries Ltd. saved to: Reliance_Industries_Ltd__stock_data.csv
Stock data for Tata Consultancy Services Ltd. saved to: Tata_Consultancy_Services_Ltd__stock_data.csv
Stock data for HDFC Bank Ltd. saved to: HDFC_Bank_Ltd__stock_data.csv
Stock data for Hindustan Unilever Ltd. saved to: Hindustan_Unilever_Ltd__stock_data.csv
Stock data for Infosys Ltd. saved to: Infosys_Ltd__stock_data.csv
Stock data for ICICI Bank Ltd. saved to: ICICI_Bank_Ltd__stock_data.csv
Stock data for Kotak Mahindra Bank Ltd. saved to: Kotak_Mahindra_Bank_Ltd__stock_data.csv
Stock data for Housing Development Finance Corporation Ltd. saved to: Housing_Development_Finance_Corporation_Ltd__stock_data.csv
Stock data for Bharti Airtel Ltd. saved to: Bharti_Airtel_Ltd__stock_data.csv
Stock data for Axis Bank Ltd. saved to: Axis_Bank_Ltd__stock_data.csv
Stock data for all companies zipped and saved to: C:\Users\Alex\Downloads\indian_stock_data2.zip

Data Cleaning¶

In [30]:
import pandas as pd
import zipfile

# Path to the zip file
zip_file_path = r'C:\Users\Alex\Downloads\indian_stock_data2.zip'

# Extract the CSV file
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
    zip_ref.extractall(r'C:\Users\Alex\Downloads')

# Load the dataset
data = pd.read_csv(r'C:\Users\Alex\Downloads\Axis_Bank_Ltd__stock_data.csv')

# Identify missing values
missing_values = data.isnull().sum()

# Imputation (replace missing values with mean)
data.fillna(data.mean(), inplace=True)

# Deletion (remove rows with missing values)
data.dropna(inplace=True)
C:\Users\Alex\AppData\Local\Temp\ipykernel_21128\1060369791.py:18: FutureWarning: The default value of numeric_only in DataFrame.mean is deprecated. In a future version, it will default to False. In addition, specifying 'numeric_only=None' is deprecated. Select only valid columns or specify the value of numeric_only to silence this warning.
  data.fillna(data.mean(), inplace=True)

Data Preprocessing:¶

In [31]:
import pandas as pd
import zipfile

# Path to the zip file
zip_file_path = r'C:\Users\Alex\Downloads\indian_stock_data2.zip'

# Extract the CSV file
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
    zip_ref.extractall(r'C:\Users\Alex\Downloads')

# Load the dataset
data = pd.read_csv(r'C:\Users\Alex\Downloads\Axis_Bank_Ltd__stock_data.csv')

# Identify missing values
missing_values = data.isnull().sum()

# Imputation (replace missing values with mean)
data.fillna(data.mean(numeric_only=True), inplace=True)

# Deletion (remove rows with missing values)
data.dropna(inplace=True)
In [7]:
import pandas as pd
import zipfile

# Path to the ZIP archive
zip_file_path = r"C:\Users\Alex\Downloads\indian_stock_data2.zip"

# Name of the CSV file
csv_file_name = 'Axis_Bank_Ltd__stock_data.csv'

# Extract the CSV file from the ZIP archive
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
    zip_ref.extract(csv_file_name, path='.')

# Load the extracted CSV file into a pandas DataFrame
df = pd.read_csv(csv_file_name)

# Now I can continue with my  analysis or data preprocessing steps
In [9]:
import pandas as pd
import zipfile

# Path to the ZIP file
zip_file_path = r"C:\Users\Alex\Downloads\indian_stock_data2.zip"

# Name of the CSV file
csv_file_name = 'Bharti_Airtel_Ltd__stock_data.csv'

# Extract the CSV file from the ZIP archive
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
    zip_ref.extract(csv_file_name, path='.')

# Load the extracted CSV file into a pandas DataFrame
df = pd.read_csv(csv_file_name)

# Now I can continue with your analysis or data preprocessing steps
In [11]:
import pandas as pd
import zipfile

# Path to the ZIP file
zip_file_path = r"C:\Users\Alex\Downloads\indian_stock_data2.zip"

# Name of the CSV file
csv_file_name = 'HDFC_Bank_Ltd__stock_data.csv'

# Extract the CSV file from the ZIP archive
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
    zip_ref.extract(csv_file_name, path='.')

# Load the extracted CSV file into a pandas DataFrame
df = pd.read_csv(csv_file_name)

# No can continue with your analysis or data preprocessing steps
In [12]:
import pandas as pd
import zipfile

# Path to the ZIP file
zip_file_path = r"C:\Users\Alex\Downloads\indian_stock_data2.zip"

# Name of the CSV file
csv_file_name = 'Hindustan_Unilever_Ltd__stock_data.csv'

# Extract the CSV file from the ZIP archive
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
    zip_ref.extract(csv_file_name, path='.')

# Load the extracted CSV file into a pandas DataFrame
df = pd.read_csv(csv_file_name)

# Now I can continue with your analysis or data preprocessing steps
In [14]:
import pandas as pd
import zipfile

# Path to the ZIP file
zip_file_path = r"C:\Users\Alex\Downloads\indian_stock_data2.zip"

# Name of the CSV file
csv_file_name = 'Housing_Development_Finance_Corporation_Ltd__stock_data.csv'

# Extract the CSV file from the ZIP archive
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
    zip_ref.extract(csv_file_name, path='.')

# Load the extracted CSV file into a pandas DataFrame
df = pd.read_csv(csv_file_name)

# Now you can continue with your analysis or data preprocessing steps
In [15]:
import pandas as pd
import zipfile

# Path to the ZIP file
zip_file_path = r"C:\Users\Alex\Downloads\indian_stock_data2.zip"

# Name of the CSV file
csv_file_name = 'ICICI_Bank_Ltd__stock_data.csv'

# Extract the CSV file from the ZIP archive
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
    zip_ref.extract(csv_file_name, path='.')

# Load the extracted CSV file into a pandas DataFrame
df = pd.read_csv(csv_file_name)

# Now I can continue with your analysis or data preprocessing steps
In [16]:
import pandas as pd
import zipfile

# Path to the ZIP file
zip_file_path = r"C:\Users\Alex\Downloads\indian_stock_data2.zip"

# Name of the CSV file
csv_file_name = 'Infosys_Ltd__stock_data.csv'

# Extract the CSV file from the ZIP archive
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
    zip_ref.extract(csv_file_name, path='.')

# Load the extracted CSV file into a pandas DataFrame
df = pd.read_csv(csv_file_name)

# Now I can continue with your analysis or data preprocessing steps
In [17]:
import pandas as pd
import zipfile

# Path to the ZIP file
zip_file_path = r"C:\Users\Alex\Downloads\indian_stock_data2.zip"

# Name of the CSV file
csv_file_name = 'Kotak_Mahindra_Bank_Ltd__stock_data.csv'

# Extract the CSV file from the ZIP archive
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
    zip_ref.extract(csv_file_name, path='.')

# Load the extracted CSV file into a pandas DataFrame
df = pd.read_csv(csv_file_name)

# Now I can continue with your analysis or data preprocessing steps
In [20]:
import pandas as pd
import zipfile

# Path to the ZIP file
zip_file_path = r"C:\Users\Alex\Downloads\indian_stock_data2.zip"

# Name of the CSV file
csv_file_name = 'Reliance_Industries_Ltd__stock_data.csv'

# Extract the CSV file from the ZIP archive
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
    zip_ref.extract(csv_file_name, path='.')

# Load the extracted CSV file into a pandas DataFrame
df = pd.read_csv(csv_file_name)

# Now I can continue with your analysis or data preprocessing steps
In [21]:
import pandas as pd
import zipfile

# Path to the ZIP file
zip_file_path = r"C:\Users\Alex\Downloads\indian_stock_data2.zip"

# Name of the CSV file
csv_file_name = 'Tata_Consultancy_Services_Ltd__stock_data.csv'

# Extract the CSV file from the ZIP archive
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
    zip_ref.extract(csv_file_name, path='.')

# Load the extracted CSV file into a pandas DataFrame
df = pd.read_csv(csv_file_name)

# Now I can continue with your analysis or data preprocessing steps
In [26]:
import pandas as pd
import numpy as np
from scipy import stats
import zipfile

# Define the path to the ZIP file
zip_file_path = r"C:\Users\Alex\Downloads\indian_stock_data2.zip"

# Define the name of the CSV file within the ZIP archive
csv_file_name = 'Axis_Bank_Ltd__stock_data.csv'

# Extract the CSV file from the ZIP archive
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
    zip_ref.extract(csv_file_name, path='.')

# Load the extracted CSV file into a pandas DataFrame
df = pd.read_csv(csv_file_name)

# Display basic information about the DataFrame
print("Original DataFrame Info:")
print(df.info())

# Handling Missing Values
# Drop rows with missing values
df.dropna(inplace=True)

# Handling Outliers
# Detect outliers using Z-score
z_scores = np.abs(stats.zscore(df.select_dtypes(include=np.number)))
outlier_threshold = 3
outliers = (z_scores > outlier_threshold).any(axis=1)

# Remove rows containing outliers
df = df[~outliers]

# Handling Inconsistencies
# Perform any necessary cleaning steps, such as correcting data types, removing duplicates, etc.

# Display basic information about the cleaned DataFrame
print("\nCleaned DataFrame Info:")
print(df.info())

# Now 'df' contains the preprocessed data and is ready for further analysis or modeling
Original DataFrame Info:
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 2463 entries, 0 to 2462
Data columns (total 7 columns):
 #   Column     Non-Null Count  Dtype  
---  ------     --------------  -----  
 0   Date       2463 non-null   object 
 1   Open       2463 non-null   float64
 2   High       2463 non-null   float64
 3   Low        2463 non-null   float64
 4   Close      2463 non-null   float64
 5   Adj Close  2463 non-null   float64
 6   Volume     2463 non-null   int64  
dtypes: float64(5), int64(1), object(1)
memory usage: 134.8+ KB
None

Cleaned DataFrame Info:
<class 'pandas.core.frame.DataFrame'>
Int64Index: 2402 entries, 0 to 2462
Data columns (total 7 columns):
 #   Column     Non-Null Count  Dtype  
---  ------     --------------  -----  
 0   Date       2402 non-null   object 
 1   Open       2402 non-null   float64
 2   High       2402 non-null   float64
 3   Low        2402 non-null   float64
 4   Close      2402 non-null   float64
 5   Adj Close  2402 non-null   float64
 6   Volume     2402 non-null   int64  
dtypes: float64(5), int64(1), object(1)
memory usage: 150.1+ KB
None
In [27]:
import pandas as pd
import numpy as np
from scipy import stats
import zipfile

# Define the path to the ZIP file
zip_file_path = r"C:\Users\Alex\Downloads\indian_stock_data2.zip"

# Define the name of the CSV file within the ZIP archive
csv_file_name = 'Bharti_Airtel_Ltd__stock_data.csv'

# Extract the CSV file from the ZIP archive
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
    zip_ref.extract(csv_file_name, path='.')

# Load the extracted CSV file into a pandas DataFrame
df = pd.read_csv(csv_file_name)

# Display basic information about the DataFrame
print("Original DataFrame Info:")
print(df.info())

# Handling Missing Values
# Drop rows with missing values
df.dropna(inplace=True)

# Handling Outliers
# Detect outliers using Z-score
z_scores = np.abs(stats.zscore(df.select_dtypes(include=np.number)))
outlier_threshold = 3
outliers = (z_scores > outlier_threshold).any(axis=1)

# Remove rows containing outliers
df = df[~outliers]

# Handling Inconsistencies
# Perform any necessary cleaning steps, such as correcting data types, removing duplicates, etc.

# Display basic information about the cleaned DataFrame
print("\nCleaned DataFrame Info:")
print(df.info())

# Now 'df' contains the preprocessed data and is ready for further analysis or modeling
Original DataFrame Info:
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 2463 entries, 0 to 2462
Data columns (total 7 columns):
 #   Column     Non-Null Count  Dtype  
---  ------     --------------  -----  
 0   Date       2463 non-null   object 
 1   Open       2463 non-null   float64
 2   High       2463 non-null   float64
 3   Low        2463 non-null   float64
 4   Close      2463 non-null   float64
 5   Adj Close  2463 non-null   float64
 6   Volume     2463 non-null   int64  
dtypes: float64(5), int64(1), object(1)
memory usage: 134.8+ KB
None

Cleaned DataFrame Info:
<class 'pandas.core.frame.DataFrame'>
Int64Index: 2406 entries, 0 to 2462
Data columns (total 7 columns):
 #   Column     Non-Null Count  Dtype  
---  ------     --------------  -----  
 0   Date       2406 non-null   object 
 1   Open       2406 non-null   float64
 2   High       2406 non-null   float64
 3   Low        2406 non-null   float64
 4   Close      2406 non-null   float64
 5   Adj Close  2406 non-null   float64
 6   Volume     2406 non-null   int64  
dtypes: float64(5), int64(1), object(1)
memory usage: 150.4+ KB
None
In [ ]:
 
In [30]:
import pandas as pd
import numpy as np
from scipy import stats
import zipfile

# Define the path to the ZIP file
zip_file_path = r"C:\Users\Alex\Downloads\indian_stock_data2.zip"

# Define the name of the CSV file within the ZIP archive
csv_file_name = 'HDFC_Bank_Ltd__stock_data.csv'

# Extract the CSV file from the ZIP archive
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
    zip_ref.extract(csv_file_name, path='.')

# Load the extracted CSV file into a pandas DataFrame
df = pd.read_csv(csv_file_name)

# Display basic information about the DataFrame
print("Original DataFrame Info:")
print(df.info())

# Handling Missing Values
# Drop rows with missing values
df.dropna(inplace=True)

# Handling Outliers
# Detect outliers using Z-score
z_scores = np.abs(stats.zscore(df.select_dtypes(include=np.number)))
outlier_threshold = 3
outliers = (z_scores > outlier_threshold).any(axis=1)

# Remove rows containing outliers
df = df[~outliers]

# Handling Inconsistencies
# Perform any necessary cleaning steps, such as correcting data types, removing duplicates, etc.

# Display basic information about the cleaned DataFrame
print("\nCleaned DataFrame Info:")
print(df.info())

# Now 'df' contains the preprocessed data and is ready for further analysis or modeling
Original DataFrame Info:
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 2463 entries, 0 to 2462
Data columns (total 7 columns):
 #   Column     Non-Null Count  Dtype  
---  ------     --------------  -----  
 0   Date       2463 non-null   object 
 1   Open       2463 non-null   float64
 2   High       2463 non-null   float64
 3   Low        2463 non-null   float64
 4   Close      2463 non-null   float64
 5   Adj Close  2463 non-null   float64
 6   Volume     2463 non-null   int64  
dtypes: float64(5), int64(1), object(1)
memory usage: 134.8+ KB
None

Cleaned DataFrame Info:
<class 'pandas.core.frame.DataFrame'>
Int64Index: 2433 entries, 0 to 2462
Data columns (total 7 columns):
 #   Column     Non-Null Count  Dtype  
---  ------     --------------  -----  
 0   Date       2433 non-null   object 
 1   Open       2433 non-null   float64
 2   High       2433 non-null   float64
 3   Low        2433 non-null   float64
 4   Close      2433 non-null   float64
 5   Adj Close  2433 non-null   float64
 6   Volume     2433 non-null   int64  
dtypes: float64(5), int64(1), object(1)
memory usage: 152.1+ KB
None
In [31]:
import pandas as pd
import numpy as np
from scipy import stats
import zipfile

# Define the path to the ZIP file
zip_file_path = r"C:\Users\Alex\Downloads\indian_stock_data2.zip"

# Define the name of the CSV file within the ZIP archive
csv_file_name = 'Housing_Development_Finance_Corporation_Ltd__stock_data.csv'

# Extract the CSV file from the ZIP archive
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
    zip_ref.extract(csv_file_name, path='.')

# Load the extracted CSV file into a pandas DataFrame
df = pd.read_csv(csv_file_name)

# Display basic information about the DataFrame
print("Original DataFrame Info:")
print(df.info())

# Handling Missing Values
# Drop rows with missing values
df.dropna(inplace=True)

# Handling Outliers
# Detect outliers using Z-score
z_scores = np.abs(stats.zscore(df.select_dtypes(include=np.number)))
outlier_threshold = 3
outliers = (z_scores > outlier_threshold).any(axis=1)

# Remove rows containing outliers
df = df[~outliers]

# Handling Inconsistencies
# Perform any necessary cleaning steps, such as correcting data types, removing duplicates, etc.

# Display basic information about the cleaned DataFrame
print("\nCleaned DataFrame Info:")
print(df.info())

# Now 'df' contains the preprocessed data and is ready for further analysis or modeling
Original DataFrame Info:
<class 'pandas.core.frame.DataFrame'>
Index: 0 entries
Data columns (total 7 columns):
 #   Column     Non-Null Count  Dtype 
---  ------     --------------  ----- 
 0   Date       0 non-null      object
 1   Open       0 non-null      object
 2   High       0 non-null      object
 3   Low        0 non-null      object
 4   Close      0 non-null      object
 5   Adj Close  0 non-null      object
 6   Volume     0 non-null      object
dtypes: object(7)
memory usage: 0.0+ bytes
None

Cleaned DataFrame Info:
<class 'pandas.core.frame.DataFrame'>
Index: 0 entries
Data columns (total 7 columns):
 #   Column     Non-Null Count  Dtype 
---  ------     --------------  ----- 
 0   Date       0 non-null      object
 1   Open       0 non-null      object
 2   High       0 non-null      object
 3   Low        0 non-null      object
 4   Close      0 non-null      object
 5   Adj Close  0 non-null      object
 6   Volume     0 non-null      object
dtypes: object(7)
memory usage: 0.0+ bytes
None
In [32]:
import pandas as pd
import numpy as np
from scipy import stats
import zipfile

# Define the path to the ZIP file
zip_file_path = r"C:\Users\Alex\Downloads\indian_stock_data2.zip"

# Define the name of the CSV file within the ZIP archive
csv_file_name = 'ICICI_Bank_Ltd__stock_data.csv'

# Extract the CSV file from the ZIP archive
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
    zip_ref.extract(csv_file_name, path='.')

# Load the extracted CSV file into a pandas DataFrame
df = pd.read_csv(csv_file_name)

# Display basic information about the DataFrame
print("Original DataFrame Info:")
print(df.info())

# Handling Missing Values
# Drop rows with missing values
df.dropna(inplace=True)

# Handling Outliers
# Detect outliers using Z-score
z_scores = np.abs(stats.zscore(df.select_dtypes(include=np.number)))
outlier_threshold = 3
outliers = (z_scores > outlier_threshold).any(axis=1)

# Remove rows containing outliers
df = df[~outliers]

# Handling Inconsistencies
# Perform any necessary cleaning steps, such as correcting data types, removing duplicates, etc.

# Display basic information about the cleaned DataFrame
print("\nCleaned DataFrame Info:")
print(df.info())

# Now 'df' contains the preprocessed data and is ready for further analysis or modeling
Original DataFrame Info:
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 2463 entries, 0 to 2462
Data columns (total 7 columns):
 #   Column     Non-Null Count  Dtype  
---  ------     --------------  -----  
 0   Date       2463 non-null   object 
 1   Open       2463 non-null   float64
 2   High       2463 non-null   float64
 3   Low        2463 non-null   float64
 4   Close      2463 non-null   float64
 5   Adj Close  2463 non-null   float64
 6   Volume     2463 non-null   int64  
dtypes: float64(5), int64(1), object(1)
memory usage: 134.8+ KB
None

Cleaned DataFrame Info:
<class 'pandas.core.frame.DataFrame'>
Int64Index: 2408 entries, 0 to 2462
Data columns (total 7 columns):
 #   Column     Non-Null Count  Dtype  
---  ------     --------------  -----  
 0   Date       2408 non-null   object 
 1   Open       2408 non-null   float64
 2   High       2408 non-null   float64
 3   Low        2408 non-null   float64
 4   Close      2408 non-null   float64
 5   Adj Close  2408 non-null   float64
 6   Volume     2408 non-null   int64  
dtypes: float64(5), int64(1), object(1)
memory usage: 150.5+ KB
None
In [33]:
import pandas as pd
import numpy as np
from scipy import stats
import zipfile

# Define the path to the ZIP file
zip_file_path = r"C:\Users\Alex\Downloads\indian_stock_data2.zip"

# Define the name of the CSV file within the ZIP archive
csv_file_name = 'Infosys_Ltd__stock_data.csv'

# Extract the CSV file from the ZIP archive
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
    zip_ref.extract(csv_file_name, path='.')

# Load the extracted CSV file into a pandas DataFrame
df = pd.read_csv(csv_file_name)

# Display basic information about the DataFrame
print("Original DataFrame Info:")
print(df.info())

# Handling Missing Values
# Drop rows with missing values
df.dropna(inplace=True)

# Handling Outliers
# Detect outliers using Z-score
z_scores = np.abs(stats.zscore(df.select_dtypes(include=np.number)))
outlier_threshold = 3
outliers = (z_scores > outlier_threshold).any(axis=1)

# Remove rows containing outliers
df = df[~outliers]

# Handling Inconsistencies
# Perform any necessary cleaning steps, such as correcting data types, removing duplicates, etc.

# Display basic information about the cleaned DataFrame
print("\nCleaned DataFrame Info:")
print(df.info())

# Now 'df' contains the preprocessed data and is ready for further analysis or modeling
Original DataFrame Info:
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 2463 entries, 0 to 2462
Data columns (total 7 columns):
 #   Column     Non-Null Count  Dtype  
---  ------     --------------  -----  
 0   Date       2463 non-null   object 
 1   Open       2463 non-null   float64
 2   High       2463 non-null   float64
 3   Low        2463 non-null   float64
 4   Close      2463 non-null   float64
 5   Adj Close  2463 non-null   float64
 6   Volume     2463 non-null   int64  
dtypes: float64(5), int64(1), object(1)
memory usage: 134.8+ KB
None

Cleaned DataFrame Info:
<class 'pandas.core.frame.DataFrame'>
Int64Index: 2406 entries, 0 to 2462
Data columns (total 7 columns):
 #   Column     Non-Null Count  Dtype  
---  ------     --------------  -----  
 0   Date       2406 non-null   object 
 1   Open       2406 non-null   float64
 2   High       2406 non-null   float64
 3   Low        2406 non-null   float64
 4   Close      2406 non-null   float64
 5   Adj Close  2406 non-null   float64
 6   Volume     2406 non-null   int64  
dtypes: float64(5), int64(1), object(1)
memory usage: 150.4+ KB
None
In [35]:
import pandas as pd
import numpy as np
from scipy import stats
import zipfile

# Define the path to the ZIP file
zip_file_path = r"C:\Users\Alex\Downloads\indian_stock_data2.zip"

# Define the name of the CSV file within the ZIP archive
csv_file_name = 'Kotak_Mahindra_Bank_Ltd__stock_data.csv'

# Extract the CSV file from the ZIP archive
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
    zip_ref.extract(csv_file_name, path='.')

# Load the extracted CSV file into a pandas DataFrame
df = pd.read_csv(csv_file_name)

# Display basic information about the DataFrame
print("Original DataFrame Info:")
print(df.info())

# Handling Missing Values
# Drop rows with missing values
df.dropna(inplace=True)

# Handling Outliers
# Detect outliers using Z-score
z_scores = np.abs(stats.zscore(df.select_dtypes(include=np.number)))
outlier_threshold = 3
outliers = (z_scores > outlier_threshold).any(axis=1)

# Remove rows containing outliers
df = df[~outliers]

# Handling Inconsistencies
# Perform any necessary cleaning steps, such as correcting data types, removing duplicates, etc.

# Display basic information about the cleaned DataFrame
print("\nCleaned DataFrame Info:")
print(df.info())

# Now 'df' contains the preprocessed data and is ready for further analysis or modeling
Original DataFrame Info:
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 2463 entries, 0 to 2462
Data columns (total 7 columns):
 #   Column     Non-Null Count  Dtype  
---  ------     --------------  -----  
 0   Date       2463 non-null   object 
 1   Open       2463 non-null   float64
 2   High       2463 non-null   float64
 3   Low        2463 non-null   float64
 4   Close      2463 non-null   float64
 5   Adj Close  2463 non-null   float64
 6   Volume     2463 non-null   int64  
dtypes: float64(5), int64(1), object(1)
memory usage: 134.8+ KB
None

Cleaned DataFrame Info:
<class 'pandas.core.frame.DataFrame'>
Int64Index: 2450 entries, 0 to 2462
Data columns (total 7 columns):
 #   Column     Non-Null Count  Dtype  
---  ------     --------------  -----  
 0   Date       2450 non-null   object 
 1   Open       2450 non-null   float64
 2   High       2450 non-null   float64
 3   Low        2450 non-null   float64
 4   Close      2450 non-null   float64
 5   Adj Close  2450 non-null   float64
 6   Volume     2450 non-null   int64  
dtypes: float64(5), int64(1), object(1)
memory usage: 153.1+ KB
None
In [36]:
import pandas as pd
import numpy as np
from scipy import stats
import zipfile

# Define the path to the ZIP file
zip_file_path = r"C:\Users\Alex\Downloads\indian_stock_data2.zip"

# Define the name of the CSV file within the ZIP archive
csv_file_name = 'Reliance_Industries_Ltd__stock_data.csv'

# Extract the CSV file from the ZIP archive
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
    zip_ref.extract(csv_file_name, path='.')

# Load the extracted CSV file into a pandas DataFrame
df = pd.read_csv(csv_file_name)

# Display basic information about the DataFrame
print("Original DataFrame Info:")
print(df.info())

# Handling Missing Values
# Drop rows with missing values
df.dropna(inplace=True)

# Handling Outliers
# Detect outliers using Z-score
z_scores = np.abs(stats.zscore(df.select_dtypes(include=np.number)))
outlier_threshold = 3
outliers = (z_scores > outlier_threshold).any(axis=1)

# Remove rows containing outliers
df = df[~outliers]

# Handling Inconsistencies
# Perform any necessary cleaning steps, such as correcting data types, removing duplicates, etc.

# Display basic information about the cleaned DataFrame
print("\nCleaned DataFrame Info:")
print(df.info())

# Now 'df' contains the preprocessed data and is ready for further analysis or modeling
Original DataFrame Info:
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 2463 entries, 0 to 2462
Data columns (total 7 columns):
 #   Column     Non-Null Count  Dtype  
---  ------     --------------  -----  
 0   Date       2463 non-null   object 
 1   Open       2463 non-null   float64
 2   High       2463 non-null   float64
 3   Low        2463 non-null   float64
 4   Close      2463 non-null   float64
 5   Adj Close  2463 non-null   float64
 6   Volume     2463 non-null   int64  
dtypes: float64(5), int64(1), object(1)
memory usage: 134.8+ KB
None

Cleaned DataFrame Info:
<class 'pandas.core.frame.DataFrame'>
Int64Index: 2411 entries, 0 to 2462
Data columns (total 7 columns):
 #   Column     Non-Null Count  Dtype  
---  ------     --------------  -----  
 0   Date       2411 non-null   object 
 1   Open       2411 non-null   float64
 2   High       2411 non-null   float64
 3   Low        2411 non-null   float64
 4   Close      2411 non-null   float64
 5   Adj Close  2411 non-null   float64
 6   Volume     2411 non-null   int64  
dtypes: float64(5), int64(1), object(1)
memory usage: 150.7+ KB
None
In [37]:
import pandas as pd
import numpy as np
from scipy import stats
import zipfile

# Define the path to the ZIP file
zip_file_path = r"C:\Users\Alex\Downloads\indian_stock_data2.zip"

# Define the name of the CSV file within the ZIP archive
csv_file_name = 'Tata_Consultancy_Services_Ltd__stock_data.csv'

# Extract the CSV file from the ZIP archive
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
    zip_ref.extract(csv_file_name, path='.')

# Load the extracted CSV file into a pandas DataFrame
df = pd.read_csv(csv_file_name)

# Display basic information about the DataFrame
print("Original DataFrame Info:")
print(df.info())

# Handling Missing Values
# Drop rows with missing values
df.dropna(inplace=True)

# Handling Outliers
# Detect outliers using Z-score
z_scores = np.abs(stats.zscore(df.select_dtypes(include=np.number)))
outlier_threshold = 3
outliers = (z_scores > outlier_threshold).any(axis=1)

# Remove rows containing outliers
df = df[~outliers]

# Handling Inconsistencies
# Perform any necessary cleaning steps, such as correcting data types, removing duplicates, etc.

# Display basic information about the cleaned DataFrame
print("\nCleaned DataFrame Info:")
print(df.info())

# Now 'df' contains the preprocessed data and is ready for further analysis or modeling
Original DataFrame Info:
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 2463 entries, 0 to 2462
Data columns (total 7 columns):
 #   Column     Non-Null Count  Dtype  
---  ------     --------------  -----  
 0   Date       2463 non-null   object 
 1   Open       2463 non-null   float64
 2   High       2463 non-null   float64
 3   Low        2463 non-null   float64
 4   Close      2463 non-null   float64
 5   Adj Close  2463 non-null   float64
 6   Volume     2463 non-null   int64  
dtypes: float64(5), int64(1), object(1)
memory usage: 134.8+ KB
None

Cleaned DataFrame Info:
<class 'pandas.core.frame.DataFrame'>
Int64Index: 2452 entries, 0 to 2462
Data columns (total 7 columns):
 #   Column     Non-Null Count  Dtype  
---  ------     --------------  -----  
 0   Date       2452 non-null   object 
 1   Open       2452 non-null   float64
 2   High       2452 non-null   float64
 3   Low        2452 non-null   float64
 4   Close      2452 non-null   float64
 5   Adj Close  2452 non-null   float64
 6   Volume     2452 non-null   int64  
dtypes: float64(5), int64(1), object(1)
memory usage: 153.2+ KB
None
In [ ]:
 
In [38]:
import pandas as pd

# Define the path to the ZIP file
zip_file_path = r"C:\Users\Alex\Downloads\indian_stock_data2.zip"

# Load the CSV file into a DataFrame
df = pd.read_csv('Axis_Bank_Ltd__stock_data.csv')

# Step 1: Date Parsing
df['Date'] = pd.to_datetime(df['Date'])

# Step 2: Feature Engineering
df['Price_Range'] = df['High'] - df['Low']
df['Daily_Return'] = df['Close'].pct_change() * 100  # Percentage change in Close price
df['MA_7'] = df['Close'].rolling(window=7).mean()  # 7-day moving average of Close price
df['MA_30'] = df['Close'].rolling(window=30).mean()  # 30-day moving average of Close price

# Step 3: Feature Scaling (if needed)
# I can use StandardScaler or MinMaxScaler from sklearn.preprocessing
 
# Step 4: Handling Categorical Data (if any)
# No categorical data in my  example

# Step 5: Dimensionality Reduction (if needed)
# I can use PCA or t-SNE from sklearn.decomposition or sklearn.manifold

# Display the modified DataFrame
print(df.head())
        Date        Open        High         Low       Close   Adj Close  \
0 2012-04-23  235.600006  237.679993  225.399994  226.889999  211.339142   
1 2012-04-24  228.380005  228.410004  217.800003  222.779999  207.510834   
2 2012-04-25  222.800003  225.000000  216.250000  218.949997  203.943314   
3 2012-04-26  219.199997  219.789993  215.229996  217.330002  202.434402   
4 2012-04-27  217.940002  223.190002  217.800003  220.800003  205.666550   

     Volume  Price_Range  Daily_Return  MA_7  MA_30  
0   7525865    12.279999           NaN   NaN    NaN  
1  12742675    10.610001     -1.811451   NaN    NaN  
2  14089155     8.750000     -1.719186   NaN    NaN  
3  10928690     4.559998     -0.739893   NaN    NaN  
4  12637520     5.389999      1.596651   NaN    NaN  
In [39]:
import pandas as pd

# Load the CSV file into a DataFrame
df = pd.read_csv('Axis_Bank_Ltd__stock_data.csv')

# Print original DataFrame
print("Original DataFrame:")
print(df.head())

# Apply preprocessing steps

# For example, convert 'Date' column to datetime
df['Date'] = pd.to_datetime(df['Date'])

# Print DataFrame after converting 'Date' column
print("\nDataFrame after converting 'Date' column:")
print(df.head())

# Perform other preprocessing steps as needed...

# Print summary statistics of numerical columns
print("\nSummary statistics of numerical columns:")
print(df.describe())

# View the last few rows of the DataFrame
print("\nLast few rows of the DataFrame:")
print(df.tail())

# Create visualizations if needed
# For example, plot histogram of 'Close' prices
df['Close'].plot.hist()
plt.title('Histogram of Close Prices')
plt.xlabel('Close Price')
plt.ylabel('Frequency')
plt.show()
Original DataFrame:
         Date        Open        High         Low       Close   Adj Close  \
0  2012-04-23  235.600006  237.679993  225.399994  226.889999  211.339142   
1  2012-04-24  228.380005  228.410004  217.800003  222.779999  207.510834   
2  2012-04-25  222.800003  225.000000  216.250000  218.949997  203.943314   
3  2012-04-26  219.199997  219.789993  215.229996  217.330002  202.434402   
4  2012-04-27  217.940002  223.190002  217.800003  220.800003  205.666550   

     Volume  
0   7525865  
1  12742675  
2  14089155  
3  10928690  
4  12637520  

DataFrame after converting 'Date' column:
        Date        Open        High         Low       Close   Adj Close  \
0 2012-04-23  235.600006  237.679993  225.399994  226.889999  211.339142   
1 2012-04-24  228.380005  228.410004  217.800003  222.779999  207.510834   
2 2012-04-25  222.800003  225.000000  216.250000  218.949997  203.943314   
3 2012-04-26  219.199997  219.789993  215.229996  217.330002  202.434402   
4 2012-04-27  217.940002  223.190002  217.800003  220.800003  205.666550   

     Volume  
0   7525865  
1  12742675  
2  14089155  
3  10928690  
4  12637520  

Summary statistics of numerical columns:
              Open         High          Low        Close    Adj Close  \
count  2463.000000  2463.000000  2463.000000  2463.000000  2463.000000   
mean    506.458308   513.222056   498.966519   506.022834   499.165110   
std     173.604317   175.192079   171.609262   173.421395   176.666824   
min     156.559998   163.399994   152.679993   156.570007   150.245224   
25%     393.800003   400.800003   386.649994   392.630005   384.815643   
50%     513.099976   519.549988   506.700012   512.900024   507.126862   
75%     638.950012   649.500000   627.975006   637.550018   634.864410   
max     848.400024   866.900024   825.450012   845.099976   842.955322   

             Volume  
count  2.463000e+03  
mean   1.153107e+07  
std    1.018144e+07  
min    0.000000e+00  
25%    5.899740e+06  
50%    8.433564e+06  
75%    1.288202e+07  
max    1.205419e+08  

Last few rows of the DataFrame:
           Date        Open        High         Low       Close   Adj Close  \
2458 2022-04-12  780.099976  801.000000  777.799988  798.450012  796.423767   
2459 2022-04-13  805.799988  805.799988  790.849976  793.049988  791.037415   
2460 2022-04-18  780.000000  801.650024  776.000000  798.849976  796.822693   
2461 2022-04-19  805.000000  816.200012  785.549988  797.799988  795.775391   
2462 2022-04-20  800.849976  802.450012  788.599976  794.700012  792.683289   

        Volume  
2458   7672215  
2459   7640132  
2460  11478317  
2461   8711816  
2462   6676491  
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[39], line 32
     29 # Create visualizations if needed
     30 # For example, plot histogram of 'Close' prices
     31 df['Close'].plot.hist()
---> 32 plt.title('Histogram of Close Prices')
     33 plt.xlabel('Close Price')
     34 plt.ylabel('Frequency')

NameError: name 'plt' is not defined
In [41]:
import pandas as pd
import matplotlib.pyplot as plt  # Import matplotlib for plotting

# Load the CSV file into a DataFrame
df = pd.read_csv('Axis_Bank_Ltd__stock_data.csv')

# Print original DataFrame
print("Original DataFrame:")
print(df.head())

# Apply preprocessing steps

# For example, convert 'Date' column to datetime
df['Date'] = pd.to_datetime(df['Date'])

# Print DataFrame after converting 'Date' column
print("\nDataFrame after converting 'Date' column:")
print(df.head())

# Perform other preprocessing steps as needed...

# Print summary statistics of numerical columns
print("\nSummary statistics of numerical columns:")
print(df.describe())

# View the last few rows of the DataFrame
print("\nLast few rows of the DataFrame:")
print(df.tail())

# Create visualizations if needed
# For example, plot histogram of 'Close' prices
df['Close'].plot.hist()
plt.title('Histogram of Close Prices')
plt.xlabel('Close Price')
plt.ylabel('Frequency')
plt.show()
Original DataFrame:
         Date        Open        High         Low       Close   Adj Close  \
0  2012-04-23  235.600006  237.679993  225.399994  226.889999  211.339142   
1  2012-04-24  228.380005  228.410004  217.800003  222.779999  207.510834   
2  2012-04-25  222.800003  225.000000  216.250000  218.949997  203.943314   
3  2012-04-26  219.199997  219.789993  215.229996  217.330002  202.434402   
4  2012-04-27  217.940002  223.190002  217.800003  220.800003  205.666550   

     Volume  
0   7525865  
1  12742675  
2  14089155  
3  10928690  
4  12637520  

DataFrame after converting 'Date' column:
        Date        Open        High         Low       Close   Adj Close  \
0 2012-04-23  235.600006  237.679993  225.399994  226.889999  211.339142   
1 2012-04-24  228.380005  228.410004  217.800003  222.779999  207.510834   
2 2012-04-25  222.800003  225.000000  216.250000  218.949997  203.943314   
3 2012-04-26  219.199997  219.789993  215.229996  217.330002  202.434402   
4 2012-04-27  217.940002  223.190002  217.800003  220.800003  205.666550   

     Volume  
0   7525865  
1  12742675  
2  14089155  
3  10928690  
4  12637520  

Summary statistics of numerical columns:
              Open         High          Low        Close    Adj Close  \
count  2463.000000  2463.000000  2463.000000  2463.000000  2463.000000   
mean    506.458308   513.222056   498.966519   506.022834   499.165110   
std     173.604317   175.192079   171.609262   173.421395   176.666824   
min     156.559998   163.399994   152.679993   156.570007   150.245224   
25%     393.800003   400.800003   386.649994   392.630005   384.815643   
50%     513.099976   519.549988   506.700012   512.900024   507.126862   
75%     638.950012   649.500000   627.975006   637.550018   634.864410   
max     848.400024   866.900024   825.450012   845.099976   842.955322   

             Volume  
count  2.463000e+03  
mean   1.153107e+07  
std    1.018144e+07  
min    0.000000e+00  
25%    5.899740e+06  
50%    8.433564e+06  
75%    1.288202e+07  
max    1.205419e+08  

Last few rows of the DataFrame:
           Date        Open        High         Low       Close   Adj Close  \
2458 2022-04-12  780.099976  801.000000  777.799988  798.450012  796.423767   
2459 2022-04-13  805.799988  805.799988  790.849976  793.049988  791.037415   
2460 2022-04-18  780.000000  801.650024  776.000000  798.849976  796.822693   
2461 2022-04-19  805.000000  816.200012  785.549988  797.799988  795.775391   
2462 2022-04-20  800.849976  802.450012  788.599976  794.700012  792.683289   

        Volume  
2458   7672215  
2459   7640132  
2460  11478317  
2461   8711816  
2462   6676491  
In [42]:
import pandas as pd
import matplotlib.pyplot as plt  # Import matplotlib for plotting

# Load the CSV file into a DataFrame
df = pd.read_csv('Bharti_Airtel_Ltd__stock_data.csv')

# Print original DataFrame
print("Original DataFrame:")
print(df.head())

# Apply preprocessing steps

# For example, convert 'Date' column to datetime
df['Date'] = pd.to_datetime(df['Date'])

# Print DataFrame after converting 'Date' column
print("\nDataFrame after converting 'Date' column:")
print(df.head())

# Perform other preprocessing steps as needed...

# Print summary statistics of numerical columns
print("\nSummary statistics of numerical columns:")
print(df.describe())

# View the last few rows of the DataFrame
print("\nLast few rows of the DataFrame:")
print(df.tail())

# Create visualizations if needed
# For example, plot histogram of 'Close' prices
df['Close'].plot.hist()
plt.title('Histogram of Close Prices')
plt.xlabel('Close Price')
plt.ylabel('Frequency')
plt.show()
Original DataFrame:
         Date        Open        High         Low       Close   Adj Close  \
0  2012-04-23  290.745605  294.260498  279.750244  281.642883  264.660217   
1  2012-04-24  275.874847  279.119385  260.418274  277.001434  260.298645   
2  2012-04-25  274.883453  284.481842  274.883453  282.093536  265.083710   
3  2012-04-26  283.896027  285.653503  275.334106  277.857605  261.103180   
4  2012-04-27  277.857605  282.093536  273.080963  277.046478  260.340973   

     Volume  
0   3988935  
1  15317269  
2   4544523  
3   6731235  
4   5027621  

DataFrame after converting 'Date' column:
        Date        Open        High         Low       Close   Adj Close  \
0 2012-04-23  290.745605  294.260498  279.750244  281.642883  264.660217   
1 2012-04-24  275.874847  279.119385  260.418274  277.001434  260.298645   
2 2012-04-25  274.883453  284.481842  274.883453  282.093536  265.083710   
3 2012-04-26  283.896027  285.653503  275.334106  277.857605  261.103180   
4 2012-04-27  277.857605  282.093536  273.080963  277.046478  260.340973   

     Volume  
0   3988935  
1  15317269  
2   4544523  
3   6731235  
4   5027621  

Summary statistics of numerical columns:
              Open         High          Low        Close    Adj Close  \
count  2463.000000  2463.000000  2463.000000  2463.000000  2463.000000   
mean    378.418515   383.942222   372.342205   377.990341   367.375508   
std     122.065332   123.460175   120.432925   121.760388   124.124932   
min     216.301743   219.771591   194.491318   218.374634   205.996841   
25%     293.809875   298.564011   289.303589   293.629623   280.833267   
50%     331.770996   336.935028   327.156372   331.888000   319.626465   
75%     437.175293   446.274445   427.613907   436.774551   428.155350   
max     775.000000   781.799988   763.000000   775.650024   768.686768   

             Volume  
count  2.463000e+03  
mean   8.564312e+06  
std    1.058016e+07  
min    0.000000e+00  
25%    3.580487e+06  
50%    5.568181e+06  
75%    9.760469e+06  
max    1.985470e+08  

Last few rows of the DataFrame:
           Date        Open        High         Low       Close   Adj Close  \
2458 2022-04-12  759.950012  759.950012  740.099976  741.650024  734.992004   
2459 2022-04-13  742.000000  756.500000  737.950012  740.650024  734.000977   
2460 2022-04-18  736.650024  740.150024  723.400024  729.500000  722.951050   
2461 2022-04-19  739.000000  739.000000  716.849976  723.500000  717.004944   
2462 2022-04-20  730.049988  744.500000  723.950012  739.349976  732.712585   

       Volume  
2458  3904026  
2459  6343030  
2460  8950327  
2461  9957060  
2462  6632292  
In [43]:
import pandas as pd
import matplotlib.pyplot as plt  # Import matplotlib for plotting

# Load the CSV file into a DataFrame
df = pd.read_csv('HDFC_Bank_Ltd__stock_data.csv')

# Print original DataFrame
print("Original DataFrame:")
print(df.head())

# Apply preprocessing steps

# For example, convert 'Date' column to datetime
df['Date'] = pd.to_datetime(df['Date'])

# Print DataFrame after converting 'Date' column
print("\nDataFrame after converting 'Date' column:")
print(df.head())

# Perform other preprocessing steps as needed...

# Print summary statistics of numerical columns
print("\nSummary statistics of numerical columns:")
print(df.describe())

# View the last few rows of the DataFrame
print("\nLast few rows of the DataFrame:")
print(df.tail())

# Create visualizations if needed
# For example, plot histogram of 'Close' prices
df['Close'].plot.hist()
plt.title('Histogram of Close Prices')
plt.xlabel('Close Price')
plt.ylabel('Frequency')
plt.show()
Original DataFrame:
         Date        Open        High         Low       Close   Adj Close  \
0  2012-04-23  275.975006  278.000000  271.649994  272.674988  249.466324   
1  2012-04-24  273.049988  273.250000  269.700012  270.924988  247.865295   
2  2012-04-25  272.000000  274.750000  269.000000  273.325012  250.061035   
3  2012-04-26  272.500000  274.975006  269.500000  270.250000  247.247757   
4  2012-04-27  271.000000  273.000000  267.100006  270.575012  247.545059   

    Volume  
0  4218824  
1  4380390  
2  5389194  
3  4669476  
4  2274510  

DataFrame after converting 'Date' column:
        Date        Open        High         Low       Close   Adj Close  \
0 2012-04-23  275.975006  278.000000  271.649994  272.674988  249.466324   
1 2012-04-24  273.049988  273.250000  269.700012  270.924988  247.865295   
2 2012-04-25  272.000000  274.750000  269.000000  273.325012  250.061035   
3 2012-04-26  272.500000  274.975006  269.500000  270.250000  247.247757   
4 2012-04-27  271.000000  273.000000  267.100006  270.575012  247.545059   

    Volume  
0  4218824  
1  4380390  
2  5389194  
3  4669476  
4  2274510  

Summary statistics of numerical columns:
              Open         High          Low        Close    Adj Close  \
count  2463.000000  2463.000000  2463.000000  2463.000000  2463.000000   
mean    811.485292   819.041077   803.055878   811.205796   779.773463   
std     408.642503   412.478318   404.162353   408.218004   404.022382   
min     244.000000   246.449997   241.100006   243.600006   222.866058   
25%     448.250000   450.675003   444.412506   446.862503   419.011597   
50%     767.525024   771.450012   748.500000   767.400024   730.930359   
75%    1117.224976  1126.924988  1103.912537  1115.287476  1084.433105   
max    1705.000000  1725.000000  1671.000000  1688.699951  1650.364746   

             Volume  
count  2.463000e+03  
mean   6.058373e+06  
std    6.474413e+06  
min    0.000000e+00  
25%    2.773356e+06  
50%    4.486782e+06  
75%    7.256966e+06  
max    2.011300e+08  

Last few rows of the DataFrame:
           Date         Open         High          Low        Close  \
2458 2022-04-12  1484.000000  1506.849976  1480.150024  1493.500000   
2459 2022-04-13  1490.000000  1502.300049  1462.650024  1464.949951   
2460 2022-04-18  1418.849976  1431.650024  1390.050049  1395.449951   
2461 2022-04-19  1380.900024  1389.550049  1327.000000  1342.199951   
2462 2022-04-20  1354.449951  1359.900024  1335.349976  1354.300049   

        Adj Close    Volume  
2458  1459.596069  13717701  
2459  1431.694092  14446260  
2460  1363.771851  22810188  
2461  1311.730713  37048011  
2462  1323.556030  24662868  
In [44]:
import pandas as pd
import matplotlib.pyplot as plt  # Import matplotlib for plotting

# Load the CSV file into a DataFrame
df = pd.read_csv('Hindustan_Unilever_Ltd__stock_data.csv')

# Print original DataFrame
print("Original DataFrame:")
print(df.head())

# Apply preprocessing steps

# For example, convert 'Date' column to datetime
df['Date'] = pd.to_datetime(df['Date'])

# Print DataFrame after converting 'Date' column
print("\nDataFrame after converting 'Date' column:")
print(df.head())

# Perform other preprocessing steps as needed...

# Print summary statistics of numerical columns
print("\nSummary statistics of numerical columns:")
print(df.describe())

# View the last few rows of the DataFrame
print("\nLast few rows of the DataFrame:")
print(df.tail())

# Create visualizations if needed
# For example, plot histogram of 'Close' prices
df['Close'].plot.hist()
plt.title('Histogram of Close Prices')
plt.xlabel('Close Price')
plt.ylabel('Frequency')
plt.show()
Original DataFrame:
         Date        Open        High         Low       Close   Adj Close  \
0  2012-04-23  422.350006  424.350006  416.000000  417.100006  340.191559   
1  2012-04-24  417.899994  423.350006  416.350006  420.500000  342.964630   
2  2012-04-25  419.350006  422.000000  416.399994  419.100006  341.822876   
3  2012-04-26  418.100006  419.850006  412.250000  414.700012  338.234100   
4  2012-04-27  414.000000  418.299988  412.549988  415.399994  338.805054   

    Volume  
0   498101  
1  1386044  
2  1021535  
3  2175667  
4  2408519  

DataFrame after converting 'Date' column:
        Date        Open        High         Low       Close   Adj Close  \
0 2012-04-23  422.350006  424.350006  416.000000  417.100006  340.191559   
1 2012-04-24  417.899994  423.350006  416.350006  420.500000  342.964630   
2 2012-04-25  419.350006  422.000000  416.399994  419.100006  341.822876   
3 2012-04-26  418.100006  419.850006  412.250000  414.700012  338.234100   
4 2012-04-27  414.000000  418.299988  412.549988  415.399994  338.805054   

    Volume  
0   498101  
1  1386044  
2  1021535  
3  2175667  
4  2408519  

Summary statistics of numerical columns:
              Open         High          Low        Close    Adj Close  \
count  2463.000000  2463.000000  2463.000000  2463.000000  2463.000000   
mean   1302.889140  1316.078338  1288.310151  1302.191920  1200.561224   
std     677.841293   684.125172   669.729497   676.451390   670.731195   
min     409.149994   415.950012   406.100006   407.299988   332.198547   
25%     750.349976   757.000000   744.875000   750.899994   649.734955   
50%     950.000000   960.000000   936.599976   952.049988   843.976196   
75%    1951.400024  1980.475037  1931.549988  1950.750000  1835.957825   
max    2827.899902  2859.300049  2796.649902  2812.449951  2710.167480   

             Volume  
count  2.463000e+03  
mean   1.801666e+06  
std    4.020897e+06  
min    0.000000e+00  
25%    9.445345e+05  
50%    1.360160e+06  
75%    2.002157e+06  
max    1.856699e+08  

Last few rows of the DataFrame:
           Date         Open         High          Low        Close  \
2458 2022-04-12  2140.899902  2165.000000  2125.000000  2132.250000   
2459 2022-04-13  2137.699951  2165.000000  2130.699951  2152.149902   
2460 2022-04-18  2148.000000  2182.899902  2135.050049  2177.649902   
2461 2022-04-19  2185.699951  2206.850098  2101.050049  2113.050049   
2462 2022-04-20  2114.399902  2168.649902  2092.699951  2164.949951   

        Adj Close   Volume  
2458  2067.331543  1370233  
2459  2086.625977  1071601  
2460  2111.349365  1828131  
2461  2048.716553  1775996  
2462  2099.036377  1511804  
In [49]:
import pandas as pd
import matplotlib.pyplot as plt  # Import matplotlib for plotting

# Load the CSV file into a DataFrame
df = pd.read_csv('ICICI_Bank_Ltd__stock_data.csv')

# Print original DataFrame
print("Original DataFrame:")
print(df.head())

# Apply preprocessing steps

# For example, convert 'Date' column to datetime
df['Date'] = pd.to_datetime(df['Date'])

# Print DataFrame after converting 'Date' column
print("\nDataFrame after converting 'Date' column:")
print(df.head())

# Perform other preprocessing steps as needed...

# Print summary statistics of numerical columns
print("\nSummary statistics of numerical columns:")
print(df.describe())

# View the last few rows of the DataFrame
print("\nLast few rows of the DataFrame:")
print(df.tail())

# Create visualizations if needed
# For example, plot histogram of 'Close' prices
df['Close'].plot.hist()
plt.title('Histogram of Close Prices')
plt.xlabel('Close Price')
plt.ylabel('Frequency')
plt.show()
Original DataFrame:
         Date        Open        High         Low       Close   Adj Close  \
0  2012-04-23  154.545456  157.909088  152.018188  153.436356  133.668579   
1  2012-04-24  154.545456  155.172729  152.418182  154.145447  134.286301   
2  2012-04-25  153.645447  155.545456  150.409088  152.436356  132.797394   
3  2012-04-26  152.754547  153.754547  151.909088  152.990906  133.280502   
4  2012-04-27  153.727264  159.090912  152.918182  156.518188  136.353363   

     Volume  
0  17939993  
1  17862146  
2  29238880  
3  24080837  
4  80624329  

DataFrame after converting 'Date' column:
        Date        Open        High         Low       Close   Adj Close  \
0 2012-04-23  154.545456  157.909088  152.018188  153.436356  133.668579   
1 2012-04-24  154.545456  155.172729  152.418182  154.145447  134.286301   
2 2012-04-25  153.645447  155.545456  150.409088  152.436356  132.797394   
3 2012-04-26  152.754547  153.754547  151.909088  152.990906  133.280502   
4 2012-04-27  153.727264  159.090912  152.918182  156.518188  136.353363   

     Volume  
0  17939993  
1  17862146  
2  29238880  
3  24080837  
4  80624329  

Summary statistics of numerical columns:
              Open         High          Low        Close    Adj Close  \
count  2463.000000  2463.000000  2463.000000  2463.000000  2463.000000   
mean    338.734990   343.030427   334.106375   338.608321   326.545910   
std     160.438005   162.080403   158.689157   160.542322   162.658872   
min     139.990906   144.527267   137.618179   142.127274   124.727226   
25%     225.386360   228.795448   222.727264   225.981819   212.746864   
50%     289.500000   292.649994   285.500000   288.818176   278.712769   
75%     389.125000   394.500000   384.675003   389.875000   382.623810   
max     830.099976   867.000000   824.200012   841.700012   829.848389   

             Volume  
count  2.463000e+03  
mean   1.995876e+07  
std    1.385090e+07  
min    0.000000e+00  
25%    1.201350e+07  
50%    1.654303e+07  
75%    2.357852e+07  
max    2.868577e+08  

Last few rows of the DataFrame:
           Date        Open        High         Low       Close   Adj Close  \
2458 2022-04-12  757.000000  768.900024  750.250000  763.849976  753.094482   
2459 2022-04-13  769.599976  772.549988  760.700012  762.250000  751.517090   
2460 2022-04-18  751.000000  762.900024  749.200012  757.799988  747.129761   
2461 2022-04-19  761.799988  777.900024  757.000000  766.299988  755.510071   
2462 2022-04-20  766.799988  770.000000  753.799988  755.549988  744.911438   

        Volume  
2458  14020000  
2459  16119956  
2460  17651530  
2461  31088359  
2462  15984202  
In [50]:
import pandas as pd
import matplotlib.pyplot as plt  # Import matplotlib for plotting

# Load the CSV file into a DataFrame
df = pd.read_csv('Infosys_Ltd__stock_data.csv')

# Print original DataFrame
print("Original DataFrame:")
print(df.head())

# Apply preprocessing steps

# For example, convert 'Date' column to datetime
df['Date'] = pd.to_datetime(df['Date'])

# Print DataFrame after converting 'Date' column
print("\nDataFrame after converting 'Date' column:")
print(df.head())

# Perform other preprocessing steps as needed...

# Print summary statistics of numerical columns
print("\nSummary statistics of numerical columns:")
print(df.describe())

# View the last few rows of the DataFrame
print("\nLast few rows of the DataFrame:")
print(df.tail())

# Create visualizations if needed
# For example, plot histogram of 'Close' prices
df['Close'].plot.hist()
plt.title('Histogram of Close Prices')
plt.xlabel('Close Price')
plt.ylabel('Frequency')
plt.show()
Original DataFrame:
         Date        Open        High         Low       Close   Adj Close  \
0  2012-04-23  298.750000  298.750000  288.125000  288.862488  221.152878   
1  2012-04-24  288.831238  295.600006  274.787506  293.693756  224.851654   
2  2012-04-25  293.712494  295.625000  287.906250  293.743744  224.889938   
3  2012-04-26  293.750000  297.350006  292.793762  294.524994  225.488083   
4  2012-04-27  294.625000  299.750000  294.375000  298.875000  228.818405   

     Volume  
0  18136696  
1  53037912  
2  24638504  
3  17137064  
4  14062464  

DataFrame after converting 'Date' column:
        Date        Open        High         Low       Close   Adj Close  \
0 2012-04-23  298.750000  298.750000  288.125000  288.862488  221.152878   
1 2012-04-24  288.831238  295.600006  274.787506  293.693756  224.851654   
2 2012-04-25  293.712494  295.625000  287.906250  293.743744  224.889938   
3 2012-04-26  293.750000  297.350006  292.793762  294.524994  225.488083   
4 2012-04-27  294.625000  299.750000  294.375000  298.875000  228.818405   

     Volume  
0  18136696  
1  53037912  
2  24638504  
3  17137064  
4  14062464  

Summary statistics of numerical columns:
              Open         High          Low        Close    Adj Close  \
count  2463.000000  2463.000000  2463.000000  2463.000000  2463.000000   
mean    690.605735   697.960508   683.203088   690.550087   608.905581   
std     396.103097   400.000174   392.123952   396.052449   394.829903   
min     270.000000   270.500000   257.568756   265.475006   204.116623   
25%     462.000000   465.015625   456.903122   461.699997   381.848175   
50%     552.637512   561.500000   547.400024   553.762512   453.840057   
75%     736.475006   742.925018   729.300018   735.274994   660.258514   
max    1938.550049  1953.900024  1930.500000  1939.500000  1849.313232   

             Volume  
count  2.463000e+03  
mean   8.841504e+06  
std    8.269084e+06  
min    0.000000e+00  
25%    5.383722e+06  
50%    7.064304e+06  
75%    9.836106e+06  
max    1.663204e+08  

Last few rows of the DataFrame:
           Date         Open         High      Low        Close    Adj Close  \
2458 2022-04-12  1757.500000  1757.500000  1727.75  1742.449951  1661.425903   
2459 2022-04-13  1754.949951  1757.500000  1732.00  1748.550049  1667.242310   
2460 2022-04-18  1605.500000  1650.000000  1590.00  1621.400024  1546.004761   
2461 2022-04-19  1636.650024  1636.650024  1550.00  1562.000000  1489.366943   
2462 2022-04-20  1575.000000  1596.300049  1563.00  1587.699951  1513.871826   

        Volume  
2458   6456184  
2459   6257693  
2460  30523965  
2461  17044923  
2462  10678747  
In [51]:
import pandas as pd
import matplotlib.pyplot as plt  # Import matplotlib for plotting

# Load the CSV file into a DataFrame
df = pd.read_csv('Kotak_Mahindra_Bank_Ltd__stock_data.csv')

# Print original DataFrame
print("Original DataFrame:")
print(df.head())

# Apply preprocessing steps

# For example, convert 'Date' column to datetime
df['Date'] = pd.to_datetime(df['Date'])

# Print DataFrame after converting 'Date' column
print("\nDataFrame after converting 'Date' column:")
print(df.head())

# Perform other preprocessing steps as needed...

# Print summary statistics of numerical columns
print("\nSummary statistics of numerical columns:")
print(df.describe())

# View the last few rows of the DataFrame
print("\nLast few rows of the DataFrame:")
print(df.tail())

# Create visualizations if needed
# For example, plot histogram of 'Close' prices
df['Close'].plot.hist()
plt.title('Histogram of Close Prices')
plt.xlabel('Close Price')
plt.ylabel('Frequency')
plt.show()
Original DataFrame:
         Date        Open        High         Low       Close   Adj Close  \
0  2012-04-23  297.975006  298.174988  287.225006  290.475006  288.207458   
1  2012-04-24  291.000000  294.225006  281.649994  284.825012  282.601562   
2  2012-04-25  285.049988  287.500000  278.750000  282.575012  280.369141   
3  2012-04-26  282.575012  292.975006  281.200012  291.424988  289.150055   
4  2012-04-27  292.250000  295.500000  287.000000  291.575012  289.298889   

    Volume  
0   706410  
1  1831874  
2  1336570  
3  1600758  
4   747874  

DataFrame after converting 'Date' column:
        Date        Open        High         Low       Close   Adj Close  \
0 2012-04-23  297.975006  298.174988  287.225006  290.475006  288.207458   
1 2012-04-24  291.000000  294.225006  281.649994  284.825012  282.601562   
2 2012-04-25  285.049988  287.500000  278.750000  282.575012  280.369141   
3 2012-04-26  282.575012  292.975006  281.200012  291.424988  289.150055   
4 2012-04-27  292.250000  295.500000  287.000000  291.575012  289.298889   

    Volume  
0   706410  
1  1831874  
2  1336570  
3  1600758  
4   747874  

Summary statistics of numerical columns:
              Open         High          Low        Close    Adj Close  \
count  2463.000000  2463.000000  2463.000000  2463.000000  2463.000000   
mean    989.465134  1001.196793   976.347391   989.191808   986.357491   
std     526.275261   532.340135   519.099136   525.750969   525.462110   
min     267.399994   269.549988   262.049988   264.774994   262.970825   
25%     536.375000   543.112488   530.024994   538.512512   535.860352   
50%     899.700012   910.000000   890.000000   900.349976   897.117676   
75%    1373.000000  1389.974976  1350.649963  1373.950012  1370.943298   
max    2200.000000  2253.000000  2176.600098  2210.949951  2207.801758   

             Volume  
count  2.463000e+03  
mean   2.559495e+06  
std    3.332796e+06  
min    0.000000e+00  
25%    1.206856e+06  
50%    1.868284e+06  
75%    2.966616e+06  
max    8.385990e+07  

Last few rows of the DataFrame:
           Date         Open         High          Low        Close  \
2458 2022-04-12  1771.050049  1812.650024  1770.000000  1801.849976   
2459 2022-04-13  1807.699951  1818.500000  1772.750000  1779.599976   
2460 2022-04-18  1775.599976  1775.599976  1730.000000  1750.400024   
2461 2022-04-19  1763.000000  1766.699951  1687.000000  1707.500000   
2462 2022-04-20  1713.000000  1727.000000  1683.400024  1721.300049   

        Adj Close   Volume  
2458  1799.284424  2412242  
2459  1777.066040  1923692  
2460  1747.907715  1960141  
2461  1705.068726  2389574  
2462  1718.849121  3201545  
In [52]:
import pandas as pd
import matplotlib.pyplot as plt  # Import matplotlib for plotting

# Load the CSV file into a DataFrame
df = pd.read_csv('Reliance_Industries_Ltd__stock_data.csv')

# Print original DataFrame
print("Original DataFrame:")
print(df.head())

# Apply preprocessing steps

# For example, convert 'Date' column to datetime
df['Date'] = pd.to_datetime(df['Date'])

# Print DataFrame after converting 'Date' column
print("\nDataFrame after converting 'Date' column:")
print(df.head())

# Perform other preprocessing steps as needed...

# Print summary statistics of numerical columns
print("\nSummary statistics of numerical columns:")
print(df.describe())

# View the last few rows of the DataFrame
print("\nLast few rows of the DataFrame:")
print(df.tail())

# Create visualizations if needed
# For example, plot histogram of 'Close' prices
df['Close'].plot.hist()
plt.title('Histogram of Close Prices')
plt.xlabel('Close Price')
plt.ylabel('Frequency')
plt.show()
Original DataFrame:
         Date        Open        High         Low       Close   Adj Close  \
0  2012-04-23  331.834198  340.931824  331.079865  336.611603  306.552368   
1  2012-04-24  337.845947  338.531677  330.851288  336.062988  306.052734   
2  2012-04-25  335.605835  339.628876  332.839966  336.611603  306.552368   
3  2012-04-26  336.977325  342.417603  335.377228  340.611786  310.195312   
4  2012-04-27  338.897430  341.571838  336.703033  339.217438  308.925476   

     Volume  
0  11053304  
1   8332450  
2   6793218  
3   7590199  
4   6250899  

DataFrame after converting 'Date' column:
        Date        Open        High         Low       Close   Adj Close  \
0 2012-04-23  331.834198  340.931824  331.079865  336.611603  306.552368   
1 2012-04-24  337.845947  338.531677  330.851288  336.062988  306.052734   
2 2012-04-25  335.605835  339.628876  332.839966  336.611603  306.552368   
3 2012-04-26  336.977325  342.417603  335.377228  340.611786  310.195312   
4 2012-04-27  338.897430  341.571838  336.703033  339.217438  308.925476   

     Volume  
0  11053304  
1   8332450  
2   6793218  
3   7590199  
4   6250899  

Summary statistics of numerical columns:
              Open         High          Low        Close    Adj Close  \
count  2463.000000  2463.000000  2463.000000  2463.000000  2463.000000   
mean    913.132283   923.600065   902.146367   912.493649   891.120904   
std     617.778037   624.854341   609.989543   617.228103   619.542913   
min     308.587280   312.153198   307.695831   309.090179   281.488556   
25%     415.998535   419.873016   410.923981   415.678497   392.020264   
50%     610.225647   614.797302   604.831116   608.808411   587.933350   
75%    1238.920776  1250.921448  1222.097107  1234.029175  1209.963257   
max    2531.557373  2539.495117  2499.483154  2521.496582  2504.449463   

             Volume  
count  2.463000e+03  
mean   9.290796e+06  
std    6.685787e+06  
min    0.000000e+00  
25%    5.554487e+06  
50%    7.390882e+06  
75%    1.049308e+07  
max    7.134168e+07  

Last few rows of the DataFrame:
           Date         Open         High          Low        Close  \
2458 2022-04-12  2387.800049  2402.198975  2358.633301  2363.848389   
2459 2022-04-13  2376.262695  2392.968994  2349.495605  2355.172119   
2460 2022-04-18  2337.958252  2362.694580  2327.620605  2347.972656   
2461 2022-04-19  2361.033203  2462.563232  2354.618408  2437.457520   
2462 2022-04-20  2452.502441  2523.481201  2445.118408  2509.128418   

        Adj Close    Volume  
2458  2347.867188   6608871  
2459  2339.249512   5177117  
2460  2332.098633   4987112  
2461  2420.978516  13070910  
2462  2492.164795  12536120  
In [53]:
import pandas as pd
import matplotlib.pyplot as plt  # Import matplotlib for plotting

# Load the CSV file into a DataFrame
df = pd.read_csv('Tata_Consultancy_Services_Ltd__stock_data.csv')

# Print original DataFrame
print("Original DataFrame:")
print(df.head())

# Apply preprocessing steps

# For example, convert 'Date' column to datetime
df['Date'] = pd.to_datetime(df['Date'])

# Print DataFrame after converting 'Date' column
print("\nDataFrame after converting 'Date' column:")
print(df.head())

# Perform other preprocessing steps as needed...

# Print summary statistics of numerical columns
print("\nSummary statistics of numerical columns:")
print(df.describe())

# View the last few rows of the DataFrame
print("\nLast few rows of the DataFrame:")
print(df.tail())

# Create visualizations if needed
# For example, plot histogram of 'Close' prices
df['Close'].plot.hist()
plt.title('Histogram of Close Prices')
plt.xlabel('Close Price')
plt.ylabel('Frequency')
plt.show()
Original DataFrame:
         Date        Open        High         Low       Close   Adj Close  \
0  2012-04-23  546.974976  551.200012  523.825012  532.125000  420.117126   
1  2012-04-24  561.000000  602.500000  558.650024  597.099976  471.415283   
2  2012-04-25  594.500000  595.000000  583.750000  585.525024  462.276855   
3  2012-04-26  585.000000  600.950012  582.250000  597.325012  471.592896   
4  2012-04-27  595.000000  606.000000  595.000000  602.000000  475.283752   

     Volume  
0   2843868  
1  18113782  
2   5417898  
3   5476292  
4   3711146  

DataFrame after converting 'Date' column:
        Date        Open        High         Low       Close   Adj Close  \
0 2012-04-23  546.974976  551.200012  523.825012  532.125000  420.117126   
1 2012-04-24  561.000000  602.500000  558.650024  597.099976  471.415283   
2 2012-04-25  594.500000  595.000000  583.750000  585.525024  462.276855   
3 2012-04-26  585.000000  600.950012  582.250000  597.325012  471.592896   
4 2012-04-27  595.000000  606.000000  595.000000  602.000000  475.283752   

     Volume  
0   2843868  
1  18113782  
2   5417898  
3   5476292  
4   3711146  

Summary statistics of numerical columns:
              Open         High          Low        Close    Adj Close  \
count  2463.000000  2463.000000  2463.000000  2463.000000  2463.000000   
mean   1683.678348  1701.228641  1665.079754  1682.933273  1504.587577   
std     847.638238   855.209727   838.780371   846.608714   841.280369   
min     546.974976   551.200012   523.825012   532.125000   420.117126   
25%    1153.837524  1166.950012  1142.437500  1157.112549   985.449951   
50%    1297.550049  1310.449951  1285.000000  1297.525024  1100.424561   
75%    2110.000000  2129.599976  2084.275024  2108.375000  1920.133606   
max    4033.949951  4043.000000  3980.000000  4019.149902  3819.472900   

             Volume  
count  2.463000e+03  
mean   2.772982e+06  
std    2.428533e+06  
min    0.000000e+00  
25%    1.692451e+06  
50%    2.317618e+06  
75%    3.239578e+06  
max    8.806715e+07  

Last few rows of the DataFrame:
           Date    Open         High          Low        Close    Adj Close  \
2458 2022-04-12  3683.0  3739.000000  3648.350098  3691.100098  3513.884766   
2459 2022-04-13  3707.0  3709.850098  3655.550049  3661.949951  3486.134277   
2460 2022-04-18  3610.0  3610.000000  3522.500000  3528.050049  3358.663330   
2461 2022-04-19  3550.0  3563.550049  3439.149902  3471.899902  3305.208740   
2462 2022-04-20  3500.0  3569.149902  3480.000000  3556.800049  3386.032715   

       Volume  
2458  4483476  
2459  1621672  
2460  3820792  
2461  3170014  
2462  2640370  
In [56]:
#  there is a problem in Housing_devleopment csv file, find the problrm
import pandas as pd
import zipfile

# Path to the ZIP file
zip_file_path = r"C:\Users\Alex\Downloads\indian_stock_data2.zip"

# Name of the CSV file
csv_file_name = 'Housing_Development_Finance_Corporation_Ltd__stock_data.csv'

# Extract the CSV file from the ZIP archive
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
    zip_ref.extract(csv_file_name, path='.')

# Read the CSV file into a DataFrame
df = pd.read_csv(csv_file_name)

# Display the first few rows of the DataFrame
print(df.head())
Empty DataFrame
Columns: [Date, Open, High, Low, Close, Adj Close, Volume]
Index: []

spit the data in to train and test data set

In [57]:
from sklearn.model_selection import train_test_split

# Load your dataset into a pandas DataFrame
# Replace 'Axis_Bank_Ltd__stock_data.csv' with the actual file path or URL of your dataset
df = pd.read_csv('Axis_Bank_Ltd__stock_data.csv')

# Define your features (X) and target variable (y)
# Adjust this based on the structure of your DataFrame
X = df.drop(columns=['Close'])  # Features excluding the 'Close' column
y = df['Close']  # Target variable

# Split the data into training and testing sets (80% train, 20% test)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Print the shapes of the training and testing sets
print("Shape of X_train:", X_train.shape)
print("Shape of X_test:", X_test.shape)
print("Shape of y_train:", y_train.shape)
print("Shape of y_test:", y_test.shape)
Shape of X_train: (1970, 6)
Shape of X_test: (493, 6)
Shape of y_train: (1970,)
Shape of y_test: (493,)
In [58]:
from sklearn.model_selection import train_test_split

# Load your dataset into a pandas DataFrame
# Replace 'Axis_Bank_Ltd__stock_data.csv' with the actual file path or URL of your dataset
df = pd.read_csv('Bharti_Airtel_Ltd__stock_data.csv')

# Define your features (X) and target variable (y)
# Adjust this based on the structure of your DataFrame
X = df.drop(columns=['Close'])  # Features excluding the 'Close' column
y = df['Close']  # Target variable

# Split the data into training and testing sets (80% train, 20% test)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Print the shapes of the training and testing sets
print("Shape of X_train:", X_train.shape)
print("Shape of X_test:", X_test.shape)
print("Shape of y_train:", y_train.shape)
print("Shape of y_test:", y_test.shape)
Shape of X_train: (1970, 6)
Shape of X_test: (493, 6)
Shape of y_train: (1970,)
Shape of y_test: (493,)
In [59]:
from sklearn.model_selection import train_test_split

# Load your dataset into a pandas DataFrame
# Replace 'Axis_Bank_Ltd__stock_data.csv' with the actual file path or URL of your dataset
df = pd.read_csv('HDFC_Bank_Ltd__stock_data.csv')

# Define your features (X) and target variable (y)
# Adjust this based on the structure of your DataFrame
X = df.drop(columns=['Close'])  # Features excluding the 'Close' column
y = df['Close']  # Target variable

# Split the data into training and testing sets (80% train, 20% test)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Print the shapes of the training and testing sets
print("Shape of X_train:", X_train.shape)
print("Shape of X_test:", X_test.shape)
print("Shape of y_train:", y_train.shape)
print("Shape of y_test:", y_test.shape)
Shape of X_train: (1970, 6)
Shape of X_test: (493, 6)
Shape of y_train: (1970,)
Shape of y_test: (493,)
In [60]:
from sklearn.model_selection import train_test_split

# Load your dataset into a pandas DataFrame
# Replace 'Axis_Bank_Ltd__stock_data.csv' with the actual file path or URL of your dataset
df = pd.read_csv('Hindustan_Unilever_Ltd__stock_data.csv')

# Define your features (X) and target variable (y)
# Adjust this based on the structure of your DataFrame
X = df.drop(columns=['Close'])  # Features excluding the 'Close' column
y = df['Close']  # Target variable

# Split the data into training and testing sets (80% train, 20% test)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Print the shapes of the training and testing sets
print("Shape of X_train:", X_train.shape)
print("Shape of X_test:", X_test.shape)
print("Shape of y_train:", y_train.shape)
print("Shape of y_test:", y_test.shape)
Shape of X_train: (1970, 6)
Shape of X_test: (493, 6)
Shape of y_train: (1970,)
Shape of y_test: (493,)
In [61]:
from sklearn.model_selection import train_test_split

# Load your dataset into a pandas DataFrame
# Replace 'Axis_Bank_Ltd__stock_data.csv' with the actual file path or URL of your dataset
df = pd.read_csv('ICICI_Bank_Ltd__stock_data.csv')

# Define your features (X) and target variable (y)
# Adjust this based on the structure of your DataFrame
X = df.drop(columns=['Close'])  # Features excluding the 'Close' column
y = df['Close']  # Target variable

# Split the data into training and testing sets (80% train, 20% test)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Print the shapes of the training and testing sets
print("Shape of X_train:", X_train.shape)
print("Shape of X_test:", X_test.shape)
print("Shape of y_train:", y_train.shape)
print("Shape of y_test:", y_test.shape)
Shape of X_train: (1970, 6)
Shape of X_test: (493, 6)
Shape of y_train: (1970,)
Shape of y_test: (493,)
In [62]:
from sklearn.model_selection import train_test_split

# Load your dataset into a pandas DataFrame
# Replace 'Axis_Bank_Ltd__stock_data.csv' with the actual file path or URL of your dataset
df = pd.read_csv('Infosys_Ltd__stock_data.csv')

# Define your features (X) and target variable (y)
# Adjust this based on the structure of your DataFrame
X = df.drop(columns=['Close'])  # Features excluding the 'Close' column
y = df['Close']  # Target variable

# Split the data into training and testing sets (80% train, 20% test)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Print the shapes of the training and testing sets
print("Shape of X_train:", X_train.shape)
print("Shape of X_test:", X_test.shape)
print("Shape of y_train:", y_train.shape)
print("Shape of y_test:", y_test.shape)
Shape of X_train: (1970, 6)
Shape of X_test: (493, 6)
Shape of y_train: (1970,)
Shape of y_test: (493,)
In [63]:
from sklearn.model_selection import train_test_split

# Load your dataset into a pandas DataFrame
# Replace 'Axis_Bank_Ltd__stock_data.csv' with the actual file path or URL of your dataset
df = pd.read_csv('Kotak_Mahindra_Bank_Ltd__stock_data.csv')

# Define your features (X) and target variable (y)
# Adjust this based on the structure of your DataFrame
X = df.drop(columns=['Close'])  # Features excluding the 'Close' column
y = df['Close']  # Target variable

# Split the data into training and testing sets (80% train, 20% test)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Print the shapes of the training and testing sets
print("Shape of X_train:", X_train.shape)
print("Shape of X_test:", X_test.shape)
print("Shape of y_train:", y_train.shape)
print("Shape of y_test:", y_test.shape)
Shape of X_train: (1970, 6)
Shape of X_test: (493, 6)
Shape of y_train: (1970,)
Shape of y_test: (493,)
In [64]:
from sklearn.model_selection import train_test_split

# Load your dataset into a pandas DataFrame
# Replace 'Axis_Bank_Ltd__stock_data.csv' with the actual file path or URL of your dataset
df = pd.read_csv('Reliance_Industries_Ltd__stock_data.csv')

# Define your features (X) and target variable (y)
# Adjust this based on the structure of your DataFrame
X = df.drop(columns=['Close'])  # Features excluding the 'Close' column
y = df['Close']  # Target variable

# Split the data into training and testing sets (80% train, 20% test)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Print the shapes of the training and testing sets
print("Shape of X_train:", X_train.shape)
print("Shape of X_test:", X_test.shape)
print("Shape of y_train:", y_train.shape)
print("Shape of y_test:", y_test.shape)
Shape of X_train: (1970, 6)
Shape of X_test: (493, 6)
Shape of y_train: (1970,)
Shape of y_test: (493,)
In [65]:
from sklearn.model_selection import train_test_split

# Load your dataset into a pandas DataFrame
# Replace 'Axis_Bank_Ltd__stock_data.csv' with the actual file path or URL of your dataset
df = pd.read_csv('Tata_Consultancy_Services_Ltd__stock_data.csv')

# Define your features (X) and target variable (y)
# Adjust this based on the structure of your DataFrame
X = df.drop(columns=['Close'])  # Features excluding the 'Close' column
y = df['Close']  # Target variable

# Split the data into training and testing sets (80% train, 20% test)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Print the shapes of the training and testing sets
print("Shape of X_train:", X_train.shape)
print("Shape of X_test:", X_test.shape)
print("Shape of y_train:", y_train.shape)
print("Shape of y_test:", y_test.shape)
Shape of X_train: (1970, 6)
Shape of X_test: (493, 6)
Shape of y_train: (1970,)
Shape of y_test: (493,)

Feature selection

In [66]:
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

# Load the data
df = pd.read_csv('Axis_Bank_Ltd__stock_data.csv')

# Calculate correlation matrix
corr_matrix = df.corr()

# Plot correlation matrix as heatmap
plt.figure(figsize=(10, 8))
sns.heatmap(corr_matrix, annot=True, cmap='coolwarm', fmt=".2f", linewidths=0.5)
plt.title('Correlation Matrix')
plt.show()

# Train a RandomForestRegressor model and extract feature importances
from sklearn.ensemble import RandomForestRegressor

# Assume X contains the features (Open, High, Low, Close, Adj Close, Volume) and y contains the target variable (Close price)
X = df[['Open', 'High', 'Low', 'Close', 'Adj Close', 'Volume']]
y = df['Close']

# Initialize and train RandomForestRegressor model
rf_model = RandomForestRegressor()
rf_model.fit(X, y)

# Extract feature importances
feature_importances = rf_model.feature_importances_

# Create a DataFrame to display feature importances
feature_importance_df = pd.DataFrame({'Feature': X.columns, 'Importance': feature_importances})
feature_importance_df.sort_values(by='Importance', ascending=False, inplace=True)

# Plot feature importances
plt.figure(figsize=(10, 6))
sns.barplot(x='Importance', y='Feature', data=feature_importance_df)
plt.title('Feature Importances')
plt.xlabel('Importance')
plt.ylabel('Feature')
plt.show()
C:\Users\Alex\AppData\Local\Temp\ipykernel_17980\3030188636.py:9: FutureWarning: The default value of numeric_only in DataFrame.corr is deprecated. In a future version, it will default to False. Select only valid columns or specify the value of numeric_only to silence this warning.
  corr_matrix = df.corr()
In [67]:
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

# Load the data
df = pd.read_csv('Bharti_Airtel_Ltd__stock_data.csv')

# Calculate correlation matrix
corr_matrix = df.corr()

# Plot correlation matrix as heatmap
plt.figure(figsize=(10, 8))
sns.heatmap(corr_matrix, annot=True, cmap='coolwarm', fmt=".2f", linewidths=0.5)
plt.title('Correlation Matrix')
plt.show()

# Train a RandomForestRegressor model and extract feature importances
from sklearn.ensemble import RandomForestRegressor

# Assume X contains the features (Open, High, Low, Close, Adj Close, Volume) and y contains the target variable (Close price)
X = df[['Open', 'High', 'Low', 'Close', 'Adj Close', 'Volume']]
y = df['Close']

# Initialize and train RandomForestRegressor model
rf_model = RandomForestRegressor()
rf_model.fit(X, y)

# Extract feature importances
feature_importances = rf_model.feature_importances_

# Create a DataFrame to display feature importances
feature_importance_df = pd.DataFrame({'Feature': X.columns, 'Importance': feature_importances})
feature_importance_df.sort_values(by='Importance', ascending=False, inplace=True)

# Plot feature importances
plt.figure(figsize=(10, 6))
sns.barplot(x='Importance', y='Feature', data=feature_importance_df)
plt.title('Feature Importances')
plt.xlabel('Importance')
plt.ylabel('Feature')
plt.show()
C:\Users\Alex\AppData\Local\Temp\ipykernel_17980\717576252.py:9: FutureWarning: The default value of numeric_only in DataFrame.corr is deprecated. In a future version, it will default to False. Select only valid columns or specify the value of numeric_only to silence this warning.
  corr_matrix = df.corr()
In [68]:
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

# Load the data
df = pd.read_csv('HDFC_Bank_Ltd__stock_data.csv')

# Calculate correlation matrix
corr_matrix = df.corr()

# Plot correlation matrix as heatmap
plt.figure(figsize=(10, 8))
sns.heatmap(corr_matrix, annot=True, cmap='coolwarm', fmt=".2f", linewidths=0.5)
plt.title('Correlation Matrix')
plt.show()

# Train a RandomForestRegressor model and extract feature importances
from sklearn.ensemble import RandomForestRegressor

# Assume X contains the features (Open, High, Low, Close, Adj Close, Volume) and y contains the target variable (Close price)
X = df[['Open', 'High', 'Low', 'Close', 'Adj Close', 'Volume']]
y = df['Close']

# Initialize and train RandomForestRegressor model
rf_model = RandomForestRegressor()
rf_model.fit(X, y)

# Extract feature importances
feature_importances = rf_model.feature_importances_

# Create a DataFrame to display feature importances
feature_importance_df = pd.DataFrame({'Feature': X.columns, 'Importance': feature_importances})
feature_importance_df.sort_values(by='Importance', ascending=False, inplace=True)

# Plot feature importances
plt.figure(figsize=(10, 6))
sns.barplot(x='Importance', y='Feature', data=feature_importance_df)
plt.title('Feature Importances')
plt.xlabel('Importance')
plt.ylabel('Feature')
plt.show()
C:\Users\Alex\AppData\Local\Temp\ipykernel_17980\2130321316.py:9: FutureWarning: The default value of numeric_only in DataFrame.corr is deprecated. In a future version, it will default to False. Select only valid columns or specify the value of numeric_only to silence this warning.
  corr_matrix = df.corr()
In [70]:
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

# Load the data
df = pd.read_csv('Axis_Bank_Ltd__stock_data.csv')

# Calculate correlation matrix
corr_matrix = df.corr(numeric_only=True)

# Plot correlation matrix as heatmap
plt.figure(figsize=(10, 8))
sns.heatmap(corr_matrix, annot=True, cmap='coolwarm', fmt=".2f", linewidths=0.5)
plt.title('Correlation Matrix')
plt.show()

# Plot feature importances
plt.figure(figsize=(10, 6))
sns.barplot(x='Importance', y='Feature', data=feature_importance_df)
plt.title('Feature Importances')
plt.xlabel('Importance')
plt.ylabel('Feature')
plt.show()
In [71]:
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

# Load the data
df = pd.read_csv('Bharti_Airtel_Ltd__stock_data.csv')

# Calculate correlation matrix
corr_matrix = df.corr(numeric_only=True)

# Plot correlation matrix as heatmap
plt.figure(figsize=(10, 8))
sns.heatmap(corr_matrix, annot=True, cmap='coolwarm', fmt=".2f", linewidths=0.5)
plt.title('Correlation Matrix')
plt.show()

# Plot feature importances
plt.figure(figsize=(10, 6))
sns.barplot(x='Importance', y='Feature', data=feature_importance_df)
plt.title('Feature Importances')
plt.xlabel('Importance')
plt.ylabel('Feature')
plt.show()
In [72]:
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

# Load the data
df = pd.read_csv('HDFC_Bank_Ltd__stock_data.csv')

# Calculate correlation matrix
corr_matrix = df.corr(numeric_only=True)

# Plot correlation matrix as heatmap
plt.figure(figsize=(10, 8))
sns.heatmap(corr_matrix, annot=True, cmap='coolwarm', fmt=".2f", linewidths=0.5)
plt.title('Correlation Matrix')
plt.show()

# Plot feature importances
plt.figure(figsize=(10, 6))
sns.barplot(x='Importance', y='Feature', data=feature_importance_df)
plt.title('Feature Importances')
plt.xlabel('Importance')
plt.ylabel('Feature')
plt.show()
In [73]:
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

# Load the data
df = pd.read_csv('Hindustan_Unilever_Ltd__stock_data.csv')

# Calculate correlation matrix
corr_matrix = df.corr(numeric_only=True)

# Plot correlation matrix as heatmap
plt.figure(figsize=(10, 8))
sns.heatmap(corr_matrix, annot=True, cmap='coolwarm', fmt=".2f", linewidths=0.5)
plt.title('Correlation Matrix')
plt.show()

# Plot feature importances
plt.figure(figsize=(10, 6))
sns.barplot(x='Importance', y='Feature', data=feature_importance_df)
plt.title('Feature Importances')
plt.xlabel('Importance')
plt.ylabel('Feature')
plt.show()
In [74]:
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

# Load the data
df = pd.read_csv('ICICI_Bank_Ltd__stock_data.csv')

# Calculate correlation matrix
corr_matrix = df.corr(numeric_only=True)

# Plot correlation matrix as heatmap
plt.figure(figsize=(10, 8))
sns.heatmap(corr_matrix, annot=True, cmap='coolwarm', fmt=".2f", linewidths=0.5)
plt.title('Correlation Matrix')
plt.show()

# Plot feature importances
plt.figure(figsize=(10, 6))
sns.barplot(x='Importance', y='Feature', data=feature_importance_df)
plt.title('Feature Importances')
plt.xlabel('Importance')
plt.ylabel('Feature')
plt.show()
In [75]:
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

# Load the data
df = pd.read_csv('Infosys_Ltd__stock_data.csv')

# Calculate correlation matrix
corr_matrix = df.corr(numeric_only=True)

# Plot correlation matrix as heatmap
plt.figure(figsize=(10, 8))
sns.heatmap(corr_matrix, annot=True, cmap='coolwarm', fmt=".2f", linewidths=0.5)
plt.title('Correlation Matrix')
plt.show()

# Plot feature importances
plt.figure(figsize=(10, 6))
sns.barplot(x='Importance', y='Feature', data=feature_importance_df)
plt.title('Feature Importances')
plt.xlabel('Importance')
plt.ylabel('Feature')
plt.show()
In [76]:
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

# Load the data
df = pd.read_csv('Kotak_Mahindra_Bank_Ltd__stock_data.csv')

# Calculate correlation matrix
corr_matrix = df.corr(numeric_only=True)

# Plot correlation matrix as heatmap
plt.figure(figsize=(10, 8))
sns.heatmap(corr_matrix, annot=True, cmap='coolwarm', fmt=".2f", linewidths=0.5)
plt.title('Correlation Matrix')
plt.show()

# Plot feature importances
plt.figure(figsize=(10, 6))
sns.barplot(x='Importance', y='Feature', data=feature_importance_df)
plt.title('Feature Importances')
plt.xlabel('Importance')
plt.ylabel('Feature')
plt.show()
In [77]:
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

# Load the data
df = pd.read_csv('Reliance_Industries_Ltd__stock_data.csv')

# Calculate correlation matrix
corr_matrix = df.corr(numeric_only=True)

# Plot correlation matrix as heatmap
plt.figure(figsize=(10, 8))
sns.heatmap(corr_matrix, annot=True, cmap='coolwarm', fmt=".2f", linewidths=0.5)
plt.title('Correlation Matrix')
plt.show()

# Plot feature importances
plt.figure(figsize=(10, 6))
sns.barplot(x='Importance', y='Feature', data=feature_importance_df)
plt.title('Feature Importances')
plt.xlabel('Importance')
plt.ylabel('Feature')
plt.show()
In [78]:
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

# Load the data
df = pd.read_csv('Tata_Consultancy_Services_Ltd__stock_data.csv')

# Calculate correlation matrix
corr_matrix = df.corr(numeric_only=True)

# Plot correlation matrix as heatmap
plt.figure(figsize=(10, 8))
sns.heatmap(corr_matrix, annot=True, cmap='coolwarm', fmt=".2f", linewidths=0.5)
plt.title('Correlation Matrix')
plt.show()

# Plot feature importances
plt.figure(figsize=(10, 6))
sns.barplot(x='Importance', y='Feature', data=feature_importance_df)
plt.title('Feature Importances')
plt.xlabel('Importance')
plt.ylabel('Feature')
plt.show()

Data Visualization: Plot the adjusted close prices over time to visually inspect the trend, seasonality, and volatility of the stock prices

In [79]:
import pandas as pd
import matplotlib.pyplot as plt

# Read the CSV file into a DataFrame
df = pd.read_csv('Axis_Bank_Ltd__stock_data.csv')

# Convert the 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Plot the adjusted close prices over time
plt.figure(figsize=(10, 6))
plt.plot(df['Date'], df['Adj Close'], color='blue', marker='o', linestyle='-')
plt.title('Adjusted Close Prices Over Time')
plt.xlabel('Date')
plt.ylabel('Adjusted Close Price')
plt.grid(True)
plt.xticks(rotation=45)  # Rotate x-axis labels for better readability
plt.tight_layout()
plt.show()
In [80]:
import pandas as pd
import matplotlib.pyplot as plt

# Read the CSV file into a DataFrame
df = pd.read_csv('Bharti_Airtel_Ltd__stock_data.csv')

# Convert the 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Plot the adjusted close prices over time
plt.figure(figsize=(10, 6))
plt.plot(df['Date'], df['Adj Close'], color='blue', marker='o', linestyle='-')
plt.title('Adjusted Close Prices Over Time')
plt.xlabel('Date')
plt.ylabel('Adjusted Close Price')
plt.grid(True)
plt.xticks(rotation=45)  # Rotate x-axis labels for better readability
plt.tight_layout()
plt.show()
In [81]:
import pandas as pd
import matplotlib.pyplot as plt

# Read the CSV file into a DataFrame
df = pd.read_csv('HDFC_Bank_Ltd__stock_data.csv')

# Convert the 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Plot the adjusted close prices over time
plt.figure(figsize=(10, 6))
plt.plot(df['Date'], df['Adj Close'], color='blue', marker='o', linestyle='-')
plt.title('Adjusted Close Prices Over Time')
plt.xlabel('Date')
plt.ylabel('Adjusted Close Price')
plt.grid(True)
plt.xticks(rotation=45)  # Rotate x-axis labels for better readability
plt.tight_layout()
plt.show()
In [82]:
import pandas as pd
import matplotlib.pyplot as plt

# Read the CSV file into a DataFrame
df = pd.read_csv('Hindustan_Unilever_Ltd__stock_data.csv')

# Convert the 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Plot the adjusted close prices over time
plt.figure(figsize=(10, 6))
plt.plot(df['Date'], df['Adj Close'], color='blue', marker='o', linestyle='-')
plt.title('Adjusted Close Prices Over Time')
plt.xlabel('Date')
plt.ylabel('Adjusted Close Price')
plt.grid(True)
plt.xticks(rotation=45)  # Rotate x-axis labels for better readability
plt.tight_layout()
plt.show()
In [83]:
import pandas as pd
import matplotlib.pyplot as plt

# Read the CSV file into a DataFrame
df = pd.read_csv('ICICI_Bank_Ltd__stock_data.csv')

# Convert the 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Plot the adjusted close prices over time
plt.figure(figsize=(10, 6))
plt.plot(df['Date'], df['Adj Close'], color='blue', marker='o', linestyle='-')
plt.title('Adjusted Close Prices Over Time')
plt.xlabel('Date')
plt.ylabel('Adjusted Close Price')
plt.grid(True)
plt.xticks(rotation=45)  # Rotate x-axis labels for better readability
plt.tight_layout()
plt.show()
In [84]:
import pandas as pd
import matplotlib.pyplot as plt

# Read the CSV file into a DataFrame
df = pd.read_csv('Infosys_Ltd__stock_data.csv')

# Convert the 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Plot the adjusted close prices over time
plt.figure(figsize=(10, 6))
plt.plot(df['Date'], df['Adj Close'], color='blue', marker='o', linestyle='-')
plt.title('Adjusted Close Prices Over Time')
plt.xlabel('Date')
plt.ylabel('Adjusted Close Price')
plt.grid(True)
plt.xticks(rotation=45)  # Rotate x-axis labels for better readability
plt.tight_layout()
plt.show()
In [85]:
import pandas as pd
import matplotlib.pyplot as plt

# Read the CSV file into a DataFrame
df = pd.read_csv('Kotak_Mahindra_Bank_Ltd__stock_data.csv')

# Convert the 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Plot the adjusted close prices over time
plt.figure(figsize=(10, 6))
plt.plot(df['Date'], df['Adj Close'], color='blue', marker='o', linestyle='-')
plt.title('Adjusted Close Prices Over Time')
plt.xlabel('Date')
plt.ylabel('Adjusted Close Price')
plt.grid(True)
plt.xticks(rotation=45)  # Rotate x-axis labels for better readability
plt.tight_layout()
plt.show()
In [86]:
import pandas as pd
import matplotlib.pyplot as plt

# Read the CSV file into a DataFrame
df = pd.read_csv('Reliance_Industries_Ltd__stock_data.csv')

# Convert the 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Plot the adjusted close prices over time
plt.figure(figsize=(10, 6))
plt.plot(df['Date'], df['Adj Close'], color='blue', marker='o', linestyle='-')
plt.title('Adjusted Close Prices Over Time')
plt.xlabel('Date')
plt.ylabel('Adjusted Close Price')
plt.grid(True)
plt.xticks(rotation=45)  # Rotate x-axis labels for better readability
plt.tight_layout()
plt.show()
In [87]:
import pandas as pd
import matplotlib.pyplot as plt

# Read the CSV file into a DataFrame
df = pd.read_csv('Tata_Consultancy_Services_Ltd__stock_data.csv')

# Convert the 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Plot the adjusted close prices over time
plt.figure(figsize=(10, 6))
plt.plot(df['Date'], df['Adj Close'], color='blue', marker='o', linestyle='-')
plt.title('Adjusted Close Prices Over Time')
plt.xlabel('Date')
plt.ylabel('Adjusted Close Price')
plt.grid(True)
plt.xticks(rotation=45)  # Rotate x-axis labels for better readability
plt.tight_layout()
plt.show()

Descriptive Statistics: Calculate basic statistics such as mean, median, standard deviation, minimum, and maximum values of the adjusted close prices. These statistics will provide insights into the central tendency and dispersion of the adjusted close prices.

In [88]:
# Calculate basic statistics for adjusted close prices
statistics = df['Adj Close'].describe()

# Print the statistics
print(statistics)
count    2463.000000
mean     1504.587577
std       841.280369
min       420.117126
25%       985.449951
50%      1100.424561
75%      1920.133606
max      3819.472900
Name: Adj Close, dtype: float64
In [89]:
# Calculate correlation matrix
corr_matrix = df.corr()

# Print correlation matrix
print(corr_matrix)
               Open      High       Low     Close  Adj Close    Volume
Open       1.000000  0.999767  0.999767  0.999531   0.999026  0.084438
High       0.999767  1.000000  0.999731  0.999815   0.999350  0.089531
Low        0.999767  0.999731  1.000000  0.999794   0.999263  0.080922
Close      0.999531  0.999815  0.999794  1.000000   0.999478  0.085191
Adj Close  0.999026  0.999350  0.999263  0.999478   1.000000  0.087535
Volume     0.084438  0.089531  0.080922  0.085191   0.087535  1.000000
C:\Users\Alex\AppData\Local\Temp\ipykernel_17980\856206223.py:2: FutureWarning: The default value of numeric_only in DataFrame.corr is deprecated. In a future version, it will default to False. Select only valid columns or specify the value of numeric_only to silence this warning.
  corr_matrix = df.corr()
In [ ]:

In [ ]:
 
In [ ]:
 

Feature Engineering: Explore the possibility of creating new features based on the adjusted close prices, such as moving averages, exponential moving averages, rate of change, or other technical indicators. Th

In [95]:
import pandas as pd
import matplotlib.pyplot as plt

# Load the data
df = pd.read_csv('Axis_Bank_Ltd__stock_data.csv')

# Convert 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Set 'Date' column as index
df.set_index('Date', inplace=True)

# Calculate moving averages
df['MA_10'] = df['Adj Close'].rolling(window=10).mean()
df['MA_50'] = df['Adj Close'].rolling(window=50).mean()

# Plot the adjusted close prices and moving averages
plt.figure(figsize=(10, 6))
plt.plot(df.index, df['Adj Close'], label='Adj Close')
plt.plot(df.index, df['MA_10'], label='10-day MA')
plt.plot(df.index, df['MA_50'], label='50-day MA')
plt.xlabel('Date')
plt.ylabel('Price')
plt.title('Adjusted Close Prices and Moving Averages')
plt.legend()
plt.show()
In [96]:
import pandas as pd
import matplotlib.pyplot as plt

# Load the data
df = pd.read_csv('Bharti_Airtel_Ltd__stock_data.csv')

# Convert 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Set 'Date' column as index
df.set_index('Date', inplace=True)

# Calculate moving averages
df['MA_10'] = df['Adj Close'].rolling(window=10).mean()
df['MA_50'] = df['Adj Close'].rolling(window=50).mean()

# Plot the adjusted close prices and moving averages
plt.figure(figsize=(10, 6))
plt.plot(df.index, df['Adj Close'], label='Adj Close')
plt.plot(df.index, df['MA_10'], label='10-day MA')
plt.plot(df.index, df['MA_50'], label='50-day MA')
plt.xlabel('Date')
plt.ylabel('Price')
plt.title('Adjusted Close Prices and Moving Averages')
plt.legend()
plt.show()
In [97]:
import pandas as pd
import matplotlib.pyplot as plt

# Load the data
df = pd.read_csv('HDFC_Bank_Ltd__stock_data.csv')

# Convert 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Set 'Date' column as index
df.set_index('Date', inplace=True)

# Calculate moving averages
df['MA_10'] = df['Adj Close'].rolling(window=10).mean()
df['MA_50'] = df['Adj Close'].rolling(window=50).mean()

# Plot the adjusted close prices and moving averages
plt.figure(figsize=(10, 6))
plt.plot(df.index, df['Adj Close'], label='Adj Close')
plt.plot(df.index, df['MA_10'], label='10-day MA')
plt.plot(df.index, df['MA_50'], label='50-day MA')
plt.xlabel('Date')
plt.ylabel('Price')
plt.title('Adjusted Close Prices and Moving Averages')
plt.legend()
plt.show()
In [98]:
import pandas as pd
import matplotlib.pyplot as plt

# Load the data
df = pd.read_csv('Hindustan_Unilever_Ltd__stock_data.csv')

# Convert 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Set 'Date' column as index
df.set_index('Date', inplace=True)

# Calculate moving averages
df['MA_10'] = df['Adj Close'].rolling(window=10).mean()
df['MA_50'] = df['Adj Close'].rolling(window=50).mean()

# Plot the adjusted close prices and moving averages
plt.figure(figsize=(10, 6))
plt.plot(df.index, df['Adj Close'], label='Adj Close')
plt.plot(df.index, df['MA_10'], label='10-day MA')
plt.plot(df.index, df['MA_50'], label='50-day MA')
plt.xlabel('Date')
plt.ylabel('Price')
plt.title('Adjusted Close Prices and Moving Averages')
plt.legend()
plt.show()
In [99]:
import pandas as pd
import matplotlib.pyplot as plt

# Load the data
df = pd.read_csv('ICICI_Bank_Ltd__stock_data.csv')

# Convert 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Set 'Date' column as index
df.set_index('Date', inplace=True)

# Calculate moving averages
df['MA_10'] = df['Adj Close'].rolling(window=10).mean()
df['MA_50'] = df['Adj Close'].rolling(window=50).mean()

# Plot the adjusted close prices and moving averages
plt.figure(figsize=(10, 6))
plt.plot(df.index, df['Adj Close'], label='Adj Close')
plt.plot(df.index, df['MA_10'], label='10-day MA')
plt.plot(df.index, df['MA_50'], label='50-day MA')
plt.xlabel('Date')
plt.ylabel('Price')
plt.title('Adjusted Close Prices and Moving Averages')
plt.legend()
plt.show()
In [100]:
import pandas as pd
import matplotlib.pyplot as plt

# Load the data
df = pd.read_csv('Infosys_Ltd__stock_data.csv')

# Convert 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Set 'Date' column as index
df.set_index('Date', inplace=True)

# Calculate moving averages
df['MA_10'] = df['Adj Close'].rolling(window=10).mean()
df['MA_50'] = df['Adj Close'].rolling(window=50).mean()

# Plot the adjusted close prices and moving averages
plt.figure(figsize=(10, 6))
plt.plot(df.index, df['Adj Close'], label='Adj Close')
plt.plot(df.index, df['MA_10'], label='10-day MA')
plt.plot(df.index, df['MA_50'], label='50-day MA')
plt.xlabel('Date')
plt.ylabel('Price')
plt.title('Adjusted Close Prices and Moving Averages')
plt.legend()
plt.show()
In [101]:
import pandas as pd
import matplotlib.pyplot as plt

# Load the data
df = pd.read_csv('Kotak_Mahindra_Bank_Ltd__stock_data.csv')

# Convert 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Set 'Date' column as index
df.set_index('Date', inplace=True)

# Calculate moving averages
df['MA_10'] = df['Adj Close'].rolling(window=10).mean()
df['MA_50'] = df['Adj Close'].rolling(window=50).mean()

# Plot the adjusted close prices and moving averages
plt.figure(figsize=(10, 6))
plt.plot(df.index, df['Adj Close'], label='Adj Close')
plt.plot(df.index, df['MA_10'], label='10-day MA')
plt.plot(df.index, df['MA_50'], label='50-day MA')
plt.xlabel('Date')
plt.ylabel('Price')
plt.title('Adjusted Close Prices and Moving Averages')
plt.legend()
plt.show()
In [102]:
import pandas as pd
import matplotlib.pyplot as plt

# Load the data
df = pd.read_csv('Reliance_Industries_Ltd__stock_data.csv')

# Convert 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Set 'Date' column as index
df.set_index('Date', inplace=True)

# Calculate moving averages
df['MA_10'] = df['Adj Close'].rolling(window=10).mean()
df['MA_50'] = df['Adj Close'].rolling(window=50).mean()

# Plot the adjusted close prices and moving averages
plt.figure(figsize=(10, 6))
plt.plot(df.index, df['Adj Close'], label='Adj Close')
plt.plot(df.index, df['MA_10'], label='10-day MA')
plt.plot(df.index, df['MA_50'], label='50-day MA')
plt.xlabel('Date')
plt.ylabel('Price')
plt.title('Adjusted Close Prices and Moving Averages')
plt.legend()
plt.show()
In [103]:
import pandas as pd
import matplotlib.pyplot as plt

# Load the data
df = pd.read_csv('Tata_Consultancy_Services_Ltd__stock_data.csv')

# Convert 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Set 'Date' column as index
df.set_index('Date', inplace=True)

# Calculate moving averages
df['MA_10'] = df['Adj Close'].rolling(window=10).mean()
df['MA_50'] = df['Adj Close'].rolling(window=50).mean()

# Plot the adjusted close prices and moving averages
plt.figure(figsize=(10, 6))
plt.plot(df.index, df['Adj Close'], label='Adj Close')
plt.plot(df.index, df['MA_10'], label='10-day MA')
plt.plot(df.index, df['MA_50'], label='50-day MA')
plt.xlabel('Date')
plt.ylabel('Price')
plt.title('Adjusted Close Prices and Moving Averages')
plt.legend()
plt.show()

EDA

In [104]:
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

# Load the dataset
df = pd.read_csv('Axis_Bank_Ltd__stock_data.csv')

# Inspect the first few rows of the dataset
print("First few rows of the dataset:")
print(df.head())

# Summary statistics
print("\nSummary statistics of numerical variables:")
print(df.describe())

# Data visualization
# Example: Plot adjusted close prices over time
plt.figure(figsize=(10, 6))
plt.plot(df['Date'], df['Adj Close'], color='blue')
plt.title('Adjusted Close Prices Over Time')
plt.xlabel('Date')
plt.ylabel('Adjusted Close Price')
plt.xticks(rotation=45)
plt.grid(True)
plt.show()

# Correlation analysis
print("\nCorrelation matrix:")
corr_matrix = df.corr()
print(corr_matrix)

# Heatmap of correlation matrix
plt.figure(figsize=(10, 6))
sns.heatmap(corr_matrix, annot=True, cmap='coolwarm', fmt=".2f")
plt.title('Correlation Heatmap')
plt.show()

# Time series analysis (if applicable)
# Example: Plotting trends, seasonality, and volatility
# (You may need additional libraries such as statsmodels for time series analysis)
First few rows of the dataset:
         Date        Open        High         Low       Close   Adj Close  \
0  2012-04-23  235.600006  237.679993  225.399994  226.889999  211.339142   
1  2012-04-24  228.380005  228.410004  217.800003  222.779999  207.510834   
2  2012-04-25  222.800003  225.000000  216.250000  218.949997  203.943314   
3  2012-04-26  219.199997  219.789993  215.229996  217.330002  202.434402   
4  2012-04-27  217.940002  223.190002  217.800003  220.800003  205.666550   

     Volume  
0   7525865  
1  12742675  
2  14089155  
3  10928690  
4  12637520  

Summary statistics of numerical variables:
              Open         High          Low        Close    Adj Close  \
count  2463.000000  2463.000000  2463.000000  2463.000000  2463.000000   
mean    506.458308   513.222056   498.966519   506.022834   499.165110   
std     173.604317   175.192079   171.609262   173.421395   176.666824   
min     156.559998   163.399994   152.679993   156.570007   150.245224   
25%     393.800003   400.800003   386.649994   392.630005   384.815643   
50%     513.099976   519.549988   506.700012   512.900024   507.126862   
75%     638.950012   649.500000   627.975006   637.550018   634.864410   
max     848.400024   866.900024   825.450012   845.099976   842.955322   

             Volume  
count  2.463000e+03  
mean   1.153107e+07  
std    1.018144e+07  
min    0.000000e+00  
25%    5.899740e+06  
50%    8.433564e+06  
75%    1.288202e+07  
max    1.205419e+08  
Correlation matrix:
               Open      High       Low     Close  Adj Close    Volume
Open       1.000000  0.999183  0.999117  0.998404   0.998154 -0.105472
High       0.999183  1.000000  0.998821  0.999324   0.999161 -0.090098
Low        0.999117  0.998821  1.000000  0.999207   0.998832 -0.117091
Close      0.998404  0.999324  0.999207  1.000000   0.999709 -0.102216
Adj Close  0.998154  0.999161  0.998832  0.999709   1.000000 -0.091888
Volume    -0.105472 -0.090098 -0.117091 -0.102216  -0.091888  1.000000
C:\Users\Alex\AppData\Local\Temp\ipykernel_17980\1870900204.py:29: FutureWarning: The default value of numeric_only in DataFrame.corr is deprecated. In a future version, it will default to False. Select only valid columns or specify the value of numeric_only to silence this warning.
  corr_matrix = df.corr()

Using Machine Learning Techniques¶

In [106]:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_squared_error

# Load the dataset
df = pd.read_csv('Axis_Bank_Ltd__stock_data.csv')

# Selecting features and target variable
X = df[['Open', 'High', 'Low', 'Adj Close', 'Volume']]  # Features (excluding 'Date')
y = df['Close']  # Target variable

# Splitting the dataset into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Scaling features
scaler = StandardScaler()
X_train_scaled = scaler.fit_transform(X_train)
X_test_scaled = scaler.transform(X_test)

# Training Random Forest model
rf_model = RandomForestRegressor(random_state=42)
rf_model.fit(X_train_scaled, y_train)

# Making predictions
y_pred = rf_model.predict(X_test_scaled)

# Evaluating the model
mse = mean_squared_error(y_test, y_pred)
print("Mean Squared Error:", mse)
Mean Squared Error: 5.163390076467977
In [113]:
!pip install tensorflow

import tensorflow as tf
print(tf.__version__)
Collecting tensorflow
  Obtaining dependency information for tensorflow from https://files.pythonhosted.org/packages/e4/14/d795bb156f8cc10eb1dcfe1332b7dbb8405b634688980aa9be8f885cc888/tensorflow-2.16.1-cp311-cp311-win_amd64.whl.metadata
  Using cached tensorflow-2.16.1-cp311-cp311-win_amd64.whl.metadata (3.5 kB)
Collecting tensorflow-intel==2.16.1 (from tensorflow)
  Obtaining dependency information for tensorflow-intel==2.16.1 from https://files.pythonhosted.org/packages/e0/36/6278e4e7e69a90c00e0f82944d8f2713dd85a69d1add455d9e50446837ab/tensorflow_intel-2.16.1-cp311-cp311-win_amd64.whl.metadata
  Using cached tensorflow_intel-2.16.1-cp311-cp311-win_amd64.whl.metadata (5.0 kB)
Collecting absl-py>=1.0.0 (from tensorflow-intel==2.16.1->tensorflow)
  Obtaining dependency information for absl-py>=1.0.0 from https://files.pythonhosted.org/packages/a2/ad/e0d3c824784ff121c03cc031f944bc7e139a8f1870ffd2845cc2dd76f6c4/absl_py-2.1.0-py3-none-any.whl.metadata
  Using cached absl_py-2.1.0-py3-none-any.whl.metadata (2.3 kB)
Collecting astunparse>=1.6.0 (from tensorflow-intel==2.16.1->tensorflow)
  Obtaining dependency information for astunparse>=1.6.0 from https://files.pythonhosted.org/packages/2b/03/13dde6512ad7b4557eb792fbcf0c653af6076b81e5941d36ec61f7ce6028/astunparse-1.6.3-py2.py3-none-any.whl.metadata
  Using cached astunparse-1.6.3-py2.py3-none-any.whl.metadata (4.4 kB)
Collecting flatbuffers>=23.5.26 (from tensorflow-intel==2.16.1->tensorflow)
  Obtaining dependency information for flatbuffers>=23.5.26 from https://files.pythonhosted.org/packages/41/f0/7e988a019bc54b2dbd0ad4182ef2d53488bb02e58694cd79d61369e85900/flatbuffers-24.3.25-py2.py3-none-any.whl.metadata
  Using cached flatbuffers-24.3.25-py2.py3-none-any.whl.metadata (850 bytes)
Collecting gast!=0.5.0,!=0.5.1,!=0.5.2,>=0.2.1 (from tensorflow-intel==2.16.1->tensorflow)
  Obtaining dependency information for gast!=0.5.0,!=0.5.1,!=0.5.2,>=0.2.1 from https://files.pythonhosted.org/packages/fa/39/5aae571e5a5f4de9c3445dae08a530498e5c53b0e74410eeeb0991c79047/gast-0.5.4-py3-none-any.whl.metadata
  Using cached gast-0.5.4-py3-none-any.whl.metadata (1.3 kB)
Collecting google-pasta>=0.1.1 (from tensorflow-intel==2.16.1->tensorflow)
  Obtaining dependency information for google-pasta>=0.1.1 from https://files.pythonhosted.org/packages/a3/de/c648ef6835192e6e2cc03f40b19eeda4382c49b5bafb43d88b931c4c74ac/google_pasta-0.2.0-py3-none-any.whl.metadata
  Using cached google_pasta-0.2.0-py3-none-any.whl.metadata (814 bytes)
Collecting h5py>=3.10.0 (from tensorflow-intel==2.16.1->tensorflow)
  Obtaining dependency information for h5py>=3.10.0 from https://files.pythonhosted.org/packages/d8/5e/b7b83cfe60504cc4d24746aed04353af7ea8ec104e597e5ae71b8d0390cb/h5py-3.11.0-cp311-cp311-win_amd64.whl.metadata
  Using cached h5py-3.11.0-cp311-cp311-win_amd64.whl.metadata (2.5 kB)
Collecting libclang>=13.0.0 (from tensorflow-intel==2.16.1->tensorflow)
  Obtaining dependency information for libclang>=13.0.0 from https://files.pythonhosted.org/packages/0b/2d/3f480b1e1d31eb3d6de5e3ef641954e5c67430d5ac93b7fa7e07589576c7/libclang-18.1.1-py2.py3-none-win_amd64.whl.metadata
  Using cached libclang-18.1.1-py2.py3-none-win_amd64.whl.metadata (5.3 kB)
Collecting ml-dtypes~=0.3.1 (from tensorflow-intel==2.16.1->tensorflow)
  Obtaining dependency information for ml-dtypes~=0.3.1 from https://files.pythonhosted.org/packages/a4/db/1784b87285588788170f87e987bfb4bda218d62a70a81ebb66c94e7f9b95/ml_dtypes-0.3.2-cp311-cp311-win_amd64.whl.metadata
  Using cached ml_dtypes-0.3.2-cp311-cp311-win_amd64.whl.metadata (20 kB)
Collecting opt-einsum>=2.3.2 (from tensorflow-intel==2.16.1->tensorflow)
  Obtaining dependency information for opt-einsum>=2.3.2 from https://files.pythonhosted.org/packages/bc/19/404708a7e54ad2798907210462fd950c3442ea51acc8790f3da48d2bee8b/opt_einsum-3.3.0-py3-none-any.whl.metadata
  Using cached opt_einsum-3.3.0-py3-none-any.whl.metadata (6.5 kB)
Requirement already satisfied: packaging in d:\new folder\lib\site-packages (from tensorflow-intel==2.16.1->tensorflow) (23.0)
Collecting protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0dev,>=3.20.3 (from tensorflow-intel==2.16.1->tensorflow)
  Obtaining dependency information for protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0dev,>=3.20.3 from https://files.pythonhosted.org/packages/ad/6e/1bed3b7c904cc178cb8ee8dbaf72934964452b3de95b7a63412591edb93c/protobuf-4.25.3-cp310-abi3-win_amd64.whl.metadata
  Using cached protobuf-4.25.3-cp310-abi3-win_amd64.whl.metadata (541 bytes)
Requirement already satisfied: requests<3,>=2.21.0 in d:\new folder\lib\site-packages (from tensorflow-intel==2.16.1->tensorflow) (2.31.0)
Requirement already satisfied: setuptools in d:\new folder\lib\site-packages (from tensorflow-intel==2.16.1->tensorflow) (68.0.0)
Requirement already satisfied: six>=1.12.0 in d:\new folder\lib\site-packages (from tensorflow-intel==2.16.1->tensorflow) (1.16.0)
Collecting termcolor>=1.1.0 (from tensorflow-intel==2.16.1->tensorflow)
  Obtaining dependency information for termcolor>=1.1.0 from https://files.pythonhosted.org/packages/d9/5f/8c716e47b3a50cbd7c146f45881e11d9414def768b7cd9c5e6650ec2a80a/termcolor-2.4.0-py3-none-any.whl.metadata
  Using cached termcolor-2.4.0-py3-none-any.whl.metadata (6.1 kB)
Requirement already satisfied: typing-extensions>=3.6.6 in d:\new folder\lib\site-packages (from tensorflow-intel==2.16.1->tensorflow) (4.7.1)
Requirement already satisfied: wrapt>=1.11.0 in d:\new folder\lib\site-packages (from tensorflow-intel==2.16.1->tensorflow) (1.14.1)
Collecting grpcio<2.0,>=1.24.3 (from tensorflow-intel==2.16.1->tensorflow)
  Obtaining dependency information for grpcio<2.0,>=1.24.3 from https://files.pythonhosted.org/packages/3c/9c/fe8b37679adf57c46323810b4d8a87b3416ca7b9721fcf816a30b35c23df/grpcio-1.62.2-cp311-cp311-win_amd64.whl.metadata
  Using cached grpcio-1.62.2-cp311-cp311-win_amd64.whl.metadata (4.2 kB)
Collecting tensorboard<2.17,>=2.16 (from tensorflow-intel==2.16.1->tensorflow)
  Obtaining dependency information for tensorboard<2.17,>=2.16 from https://files.pythonhosted.org/packages/3a/d0/b97889ffa769e2d1fdebb632084d5e8b53fc299d43a537acee7ec0c021a3/tensorboard-2.16.2-py3-none-any.whl.metadata
  Using cached tensorboard-2.16.2-py3-none-any.whl.metadata (1.6 kB)
Collecting keras>=3.0.0 (from tensorflow-intel==2.16.1->tensorflow)
  Obtaining dependency information for keras>=3.0.0 from https://files.pythonhosted.org/packages/54/b4/9b454f5264ada7c30c889d87b454466fd9ca28cb1bb271dedab2335f946a/keras-3.3.2-py3-none-any.whl.metadata
  Using cached keras-3.3.2-py3-none-any.whl.metadata (5.7 kB)
Collecting tensorflow-io-gcs-filesystem>=0.23.1 (from tensorflow-intel==2.16.1->tensorflow)
  Obtaining dependency information for tensorflow-io-gcs-filesystem>=0.23.1 from https://files.pythonhosted.org/packages/ac/4e/9566a313927be582ca99455a9523a097c7888fc819695bdc08415432b202/tensorflow_io_gcs_filesystem-0.31.0-cp311-cp311-win_amd64.whl.metadata
  Using cached tensorflow_io_gcs_filesystem-0.31.0-cp311-cp311-win_amd64.whl.metadata (14 kB)
Requirement already satisfied: numpy<2.0.0,>=1.23.5 in d:\new folder\lib\site-packages (from tensorflow-intel==2.16.1->tensorflow) (1.24.3)
Requirement already satisfied: wheel<1.0,>=0.23.0 in d:\new folder\lib\site-packages (from astunparse>=1.6.0->tensorflow-intel==2.16.1->tensorflow) (0.38.4)
Collecting rich (from keras>=3.0.0->tensorflow-intel==2.16.1->tensorflow)
  Obtaining dependency information for rich from https://files.pythonhosted.org/packages/87/67/a37f6214d0e9fe57f6ae54b2956d550ca8365857f42a1ce0392bb21d9410/rich-13.7.1-py3-none-any.whl.metadata
  Using cached rich-13.7.1-py3-none-any.whl.metadata (18 kB)
Collecting namex (from keras>=3.0.0->tensorflow-intel==2.16.1->tensorflow)
  Obtaining dependency information for namex from https://files.pythonhosted.org/packages/73/59/7854fbfb59f8ae35483ce93493708be5942ebb6328cd85b3a609df629736/namex-0.0.8-py3-none-any.whl.metadata
  Using cached namex-0.0.8-py3-none-any.whl.metadata (246 bytes)
Collecting optree (from keras>=3.0.0->tensorflow-intel==2.16.1->tensorflow)
  Obtaining dependency information for optree from https://files.pythonhosted.org/packages/8f/db/e05a35451d4ba30fdc65ef168dfdc68a6939ea6afdc0101e3e77f97e1547/optree-0.11.0-cp311-cp311-win_amd64.whl.metadata
  Using cached optree-0.11.0-cp311-cp311-win_amd64.whl.metadata (46 kB)
Requirement already satisfied: charset-normalizer<4,>=2 in d:\new folder\lib\site-packages (from requests<3,>=2.21.0->tensorflow-intel==2.16.1->tensorflow) (2.0.4)
Requirement already satisfied: idna<4,>=2.5 in d:\new folder\lib\site-packages (from requests<3,>=2.21.0->tensorflow-intel==2.16.1->tensorflow) (3.4)
Requirement already satisfied: urllib3<3,>=1.21.1 in d:\new folder\lib\site-packages (from requests<3,>=2.21.0->tensorflow-intel==2.16.1->tensorflow) (1.26.16)
Requirement already satisfied: certifi>=2017.4.17 in d:\new folder\lib\site-packages (from requests<3,>=2.21.0->tensorflow-intel==2.16.1->tensorflow) (2023.7.22)
Requirement already satisfied: markdown>=2.6.8 in d:\new folder\lib\site-packages (from tensorboard<2.17,>=2.16->tensorflow-intel==2.16.1->tensorflow) (3.4.1)
Collecting tensorboard-data-server<0.8.0,>=0.7.0 (from tensorboard<2.17,>=2.16->tensorflow-intel==2.16.1->tensorflow)
  Obtaining dependency information for tensorboard-data-server<0.8.0,>=0.7.0 from https://files.pythonhosted.org/packages/7a/13/e503968fefabd4c6b2650af21e110aa8466fe21432cd7c43a84577a89438/tensorboard_data_server-0.7.2-py3-none-any.whl.metadata
  Using cached tensorboard_data_server-0.7.2-py3-none-any.whl.metadata (1.1 kB)
Requirement already satisfied: werkzeug>=1.0.1 in d:\new folder\lib\site-packages (from tensorboard<2.17,>=2.16->tensorflow-intel==2.16.1->tensorflow) (2.2.3)
Requirement already satisfied: MarkupSafe>=2.1.1 in d:\new folder\lib\site-packages (from werkzeug>=1.0.1->tensorboard<2.17,>=2.16->tensorflow-intel==2.16.1->tensorflow) (2.1.1)
Requirement already satisfied: markdown-it-py>=2.2.0 in d:\new folder\lib\site-packages (from rich->keras>=3.0.0->tensorflow-intel==2.16.1->tensorflow) (2.2.0)
Requirement already satisfied: pygments<3.0.0,>=2.13.0 in d:\new folder\lib\site-packages (from rich->keras>=3.0.0->tensorflow-intel==2.16.1->tensorflow) (2.15.1)
Requirement already satisfied: mdurl~=0.1 in d:\new folder\lib\site-packages (from markdown-it-py>=2.2.0->rich->keras>=3.0.0->tensorflow-intel==2.16.1->tensorflow) (0.1.0)
Using cached tensorflow-2.16.1-cp311-cp311-win_amd64.whl (2.1 kB)
Downloading tensorflow_intel-2.16.1-cp311-cp311-win_amd64.whl (377.0 MB)
   ---------------------------------------- 0.0/377.0 MB ? eta -:--:--
   ---------------------------------------- 0.1/377.0 MB 2.9 MB/s eta 0:02:11
   ---------------------------------------- 0.4/377.0 MB 4.4 MB/s eta 0:01:26
   ---------------------------------------- 0.4/377.0 MB 4.4 MB/s eta 0:01:26
   ---------------------------------------- 0.4/377.0 MB 2.8 MB/s eta 0:02:17
   ---------------------------------------- 1.1/377.0 MB 5.1 MB/s eta 0:01:14
   ---------------------------------------- 1.3/377.0 MB 5.0 MB/s eta 0:01:15
   ---------------------------------------- 1.5/377.0 MB 4.9 MB/s eta 0:01:17
   ---------------------------------------- 1.8/377.0 MB 4.9 MB/s eta 0:01:17
   ---------------------------------------- 1.9/377.0 MB 4.6 MB/s eta 0:01:22
   ---------------------------------------- 2.1/377.0 MB 4.6 MB/s eta 0:01:23
   ---------------------------------------- 2.2/377.0 MB 4.4 MB/s eta 0:01:25
   ---------------------------------------- 2.2/377.0 MB 4.2 MB/s eta 0:01:30
   ---------------------------------------- 2.3/377.0 MB 4.0 MB/s eta 0:01:34
   ---------------------------------------- 2.3/377.0 MB 3.7 MB/s eta 0:01:42
   ---------------------------------------- 2.4/377.0 MB 3.4 MB/s eta 0:01:49
   ---------------------------------------- 2.4/377.0 MB 3.3 MB/s eta 0:01:54
   ---------------------------------------- 2.5/377.0 MB 3.1 MB/s eta 0:02:00
   ---------------------------------------- 2.5/377.0 MB 3.1 MB/s eta 0:02:00
   ---------------------------------------- 2.5/377.0 MB 2.9 MB/s eta 0:02:09
   ---------------------------------------- 2.5/377.0 MB 2.8 MB/s eta 0:02:15
   ---------------------------------------- 2.6/377.0 MB 2.7 MB/s eta 0:02:21
   ---------------------------------------- 2.6/377.0 MB 2.6 MB/s eta 0:02:24
   ---------------------------------------- 2.6/377.0 MB 2.5 MB/s eta 0:02:32
   ---------------------------------------- 2.7/377.0 MB 2.5 MB/s eta 0:02:33
   ---------------------------------------- 2.7/377.0 MB 2.5 MB/s eta 0:02:33
   ---------------------------------------- 2.7/377.0 MB 2.2 MB/s eta 0:02:50
   ---------------------------------------- 2.7/377.0 MB 2.2 MB/s eta 0:02:53
   ---------------------------------------- 2.7/377.0 MB 2.2 MB/s eta 0:02:53
   ---------------------------------------- 2.7/377.0 MB 2.1 MB/s eta 0:03:01
   ---------------------------------------- 2.8/377.0 MB 2.0 MB/s eta 0:03:04
   ---------------------------------------- 2.8/377.0 MB 2.0 MB/s eta 0:03:07
   ---------------------------------------- 2.9/377.0 MB 2.0 MB/s eta 0:03:11
   ---------------------------------------- 2.9/377.0 MB 2.0 MB/s eta 0:03:11
   ---------------------------------------- 3.0/377.0 MB 1.9 MB/s eta 0:03:13
   ---------------------------------------- 3.1/377.0 MB 1.9 MB/s eta 0:03:15
   ---------------------------------------- 3.1/377.0 MB 1.9 MB/s eta 0:03:17
   ---------------------------------------- 3.2/377.0 MB 1.9 MB/s eta 0:03:17
   ---------------------------------------- 3.2/377.0 MB 1.9 MB/s eta 0:03:21
   ---------------------------------------- 3.3/377.0 MB 1.8 MB/s eta 0:03:23
   ---------------------------------------- 3.4/377.0 MB 1.9 MB/s eta 0:03:22
   ---------------------------------------- 3.5/377.0 MB 1.8 MB/s eta 0:03:23
   ---------------------------------------- 3.6/377.0 MB 1.8 MB/s eta 0:03:23
   ---------------------------------------- 3.7/377.0 MB 1.9 MB/s eta 0:03:21
   ---------------------------------------- 3.8/377.0 MB 1.9 MB/s eta 0:03:21
   ---------------------------------------- 3.9/377.0 MB 1.9 MB/s eta 0:03:21
   ---------------------------------------- 4.0/377.0 MB 1.9 MB/s eta 0:03:17
   ---------------------------------------- 4.1/377.0 MB 1.9 MB/s eta 0:03:17
   ---------------------------------------- 4.2/377.0 MB 1.9 MB/s eta 0:03:14
   ---------------------------------------- 4.4/377.0 MB 1.9 MB/s eta 0:03:13
   ---------------------------------------- 4.5/377.0 MB 1.9 MB/s eta 0:03:12
   ---------------------------------------- 4.6/377.0 MB 2.0 MB/s eta 0:03:10
    --------------------------------------- 4.7/377.0 MB 2.0 MB/s eta 0:03:09
    --------------------------------------- 4.9/377.0 MB 2.0 MB/s eta 0:03:06
    --------------------------------------- 5.0/377.0 MB 2.0 MB/s eta 0:03:04
    --------------------------------------- 5.2/377.0 MB 2.0 MB/s eta 0:03:02
    --------------------------------------- 5.3/377.0 MB 2.1 MB/s eta 0:03:00
    --------------------------------------- 5.5/377.0 MB 2.1 MB/s eta 0:02:58
    --------------------------------------- 5.6/377.0 MB 2.1 MB/s eta 0:02:57
    --------------------------------------- 5.8/377.0 MB 2.1 MB/s eta 0:02:54
    --------------------------------------- 6.0/377.0 MB 2.2 MB/s eta 0:02:52
    --------------------------------------- 6.1/377.0 MB 2.2 MB/s eta 0:02:51
    --------------------------------------- 6.1/377.0 MB 2.2 MB/s eta 0:02:52
    --------------------------------------- 6.3/377.0 MB 2.2 MB/s eta 0:02:51
    --------------------------------------- 6.5/377.0 MB 2.2 MB/s eta 0:02:49
    --------------------------------------- 6.6/377.0 MB 2.2 MB/s eta 0:02:47
    --------------------------------------- 6.8/377.0 MB 2.3 MB/s eta 0:02:44
    --------------------------------------- 7.0/377.0 MB 2.3 MB/s eta 0:02:43
    --------------------------------------- 7.2/377.0 MB 2.3 MB/s eta 0:02:41
    --------------------------------------- 7.4/377.0 MB 2.3 MB/s eta 0:02:39
    --------------------------------------- 7.6/377.0 MB 2.4 MB/s eta 0:02:37
    --------------------------------------- 7.8/377.0 MB 2.4 MB/s eta 0:02:36
    --------------------------------------- 8.0/377.0 MB 2.4 MB/s eta 0:02:34
    --------------------------------------- 8.2/377.0 MB 2.4 MB/s eta 0:02:32
    --------------------------------------- 8.4/377.0 MB 2.5 MB/s eta 0:02:30
    --------------------------------------- 8.6/377.0 MB 2.5 MB/s eta 0:02:28
    --------------------------------------- 8.8/377.0 MB 2.5 MB/s eta 0:02:26
    --------------------------------------- 9.0/377.0 MB 2.6 MB/s eta 0:02:24
    --------------------------------------- 9.2/377.0 MB 2.6 MB/s eta 0:02:23
   - -------------------------------------- 9.5/377.0 MB 2.6 MB/s eta 0:02:20
   - -------------------------------------- 9.6/377.0 MB 2.6 MB/s eta 0:02:21
   - -------------------------------------- 9.9/377.0 MB 2.7 MB/s eta 0:02:19
   - -------------------------------------- 10.1/377.0 MB 2.7 MB/s eta 0:02:17
   - -------------------------------------- 10.3/377.0 MB 2.7 MB/s eta 0:02:16
   - -------------------------------------- 10.6/377.0 MB 2.7 MB/s eta 0:02:16
   - -------------------------------------- 10.8/377.0 MB 2.8 MB/s eta 0:02:13
   - -------------------------------------- 10.9/377.0 MB 2.7 MB/s eta 0:02:15
   - -------------------------------------- 11.2/377.0 MB 2.7 MB/s eta 0:02:17
   - -------------------------------------- 11.5/377.0 MB 2.7 MB/s eta 0:02:17
   - -------------------------------------- 11.8/377.0 MB 2.7 MB/s eta 0:02:15
   - -------------------------------------- 12.0/377.0 MB 2.7 MB/s eta 0:02:15
   - -------------------------------------- 12.2/377.0 MB 2.7 MB/s eta 0:02:15
   - -------------------------------------- 12.5/377.0 MB 2.8 MB/s eta 0:02:12
   - -------------------------------------- 12.7/377.0 MB 2.9 MB/s eta 0:02:04
   - -------------------------------------- 12.9/377.0 MB 3.3 MB/s eta 0:01:51
   - -------------------------------------- 13.1/377.0 MB 3.5 MB/s eta 0:01:44
   - -------------------------------------- 13.3/377.0 MB 3.7 MB/s eta 0:01:40
   - -------------------------------------- 13.5/377.0 MB 3.8 MB/s eta 0:01:36
   - -------------------------------------- 13.8/377.0 MB 4.0 MB/s eta 0:01:32
   - -------------------------------------- 14.0/377.0 MB 4.0 MB/s eta 0:01:31
   - -------------------------------------- 14.2/377.0 MB 4.1 MB/s eta 0:01:29
   - -------------------------------------- 14.4/377.0 MB 4.2 MB/s eta 0:01:27
   - -------------------------------------- 14.6/377.0 MB 4.1 MB/s eta 0:01:28
   - -------------------------------------- 14.8/377.0 MB 4.2 MB/s eta 0:01:26
   - -------------------------------------- 15.0/377.0 MB 4.3 MB/s eta 0:01:25
   - -------------------------------------- 15.3/377.0 MB 4.3 MB/s eta 0:01:24
   - -------------------------------------- 15.5/377.0 MB 4.4 MB/s eta 0:01:23
   - -------------------------------------- 15.7/377.0 MB 4.4 MB/s eta 0:01:22
   - -------------------------------------- 16.0/377.0 MB 4.5 MB/s eta 0:01:22
   - -------------------------------------- 16.0/377.0 MB 4.4 MB/s eta 0:01:23
   - -------------------------------------- 16.2/377.0 MB 4.4 MB/s eta 0:01:23
   - -------------------------------------- 16.4/377.0 MB 4.5 MB/s eta 0:01:20
   - -------------------------------------- 16.6/377.0 MB 4.5 MB/s eta 0:01:20
   - -------------------------------------- 16.9/377.0 MB 4.6 MB/s eta 0:01:19
   - -------------------------------------- 17.1/377.0 MB 4.6 MB/s eta 0:01:19
   - -------------------------------------- 17.4/377.0 MB 4.6 MB/s eta 0:01:18
   - -------------------------------------- 17.6/377.0 MB 4.6 MB/s eta 0:01:18
   - -------------------------------------- 17.8/377.0 MB 4.7 MB/s eta 0:01:17
   - -------------------------------------- 18.1/377.0 MB 4.7 MB/s eta 0:01:17
   - -------------------------------------- 18.3/377.0 MB 4.7 MB/s eta 0:01:17
   - -------------------------------------- 18.4/377.0 MB 4.7 MB/s eta 0:01:16
   - -------------------------------------- 18.5/377.0 MB 4.7 MB/s eta 0:01:17
   - -------------------------------------- 18.6/377.0 MB 4.6 MB/s eta 0:01:19
   - -------------------------------------- 18.7/377.0 MB 4.5 MB/s eta 0:01:19
   - -------------------------------------- 18.8/377.0 MB 4.5 MB/s eta 0:01:20
   - -------------------------------------- 18.8/377.0 MB 4.4 MB/s eta 0:01:21
   -- ------------------------------------- 18.9/377.0 MB 4.3 MB/s eta 0:01:23
   -- ------------------------------------- 19.0/377.0 MB 4.3 MB/s eta 0:01:24
   -- ------------------------------------- 19.1/377.0 MB 4.2 MB/s eta 0:01:25
   -- ------------------------------------- 19.1/377.0 MB 4.2 MB/s eta 0:01:26
   -- ------------------------------------- 19.2/377.0 MB 4.1 MB/s eta 0:01:27
   -- ------------------------------------- 19.3/377.0 MB 4.1 MB/s eta 0:01:28
   -- ------------------------------------- 19.4/377.0 MB 4.0 MB/s eta 0:01:29
   -- ------------------------------------- 19.4/377.0 MB 4.0 MB/s eta 0:01:29
   -- ------------------------------------- 19.4/377.0 MB 3.9 MB/s eta 0:01:32
   -- ------------------------------------- 19.5/377.0 MB 3.9 MB/s eta 0:01:32
   -- ------------------------------------- 19.6/377.0 MB 3.8 MB/s eta 0:01:34
   -- ------------------------------------- 19.7/377.0 MB 3.8 MB/s eta 0:01:35
   -- ------------------------------------- 19.8/377.0 MB 3.8 MB/s eta 0:01:34
   -- ------------------------------------- 19.9/377.0 MB 3.8 MB/s eta 0:01:35
   -- ------------------------------------- 20.0/377.0 MB 3.7 MB/s eta 0:01:36
   -- ------------------------------------- 20.2/377.0 MB 3.7 MB/s eta 0:01:37
   -- ------------------------------------- 20.3/377.0 MB 3.6 MB/s eta 0:01:39
   -- ------------------------------------- 20.4/377.0 MB 3.6 MB/s eta 0:01:39
   -- ------------------------------------- 20.5/377.0 MB 3.6 MB/s eta 0:01:39
   -- ------------------------------------- 20.6/377.0 MB 3.6 MB/s eta 0:01:40
   -- ------------------------------------- 20.7/377.0 MB 3.6 MB/s eta 0:01:41
   -- ------------------------------------- 20.9/377.0 MB 3.5 MB/s eta 0:01:42
   -- ------------------------------------- 21.0/377.0 MB 3.5 MB/s eta 0:01:41
   -- ------------------------------------- 21.2/377.0 MB 3.5 MB/s eta 0:01:42
   -- ------------------------------------- 21.3/377.0 MB 3.5 MB/s eta 0:01:42
   -- ------------------------------------- 21.5/377.0 MB 3.5 MB/s eta 0:01:43
   -- ------------------------------------- 21.7/377.0 MB 3.4 MB/s eta 0:01:44
   -- ------------------------------------- 21.8/377.0 MB 3.4 MB/s eta 0:01:44
   -- ------------------------------------- 22.0/377.0 MB 3.4 MB/s eta 0:01:44
   -- ------------------------------------- 22.1/377.0 MB 3.4 MB/s eta 0:01:45
   -- ------------------------------------- 22.3/377.0 MB 3.4 MB/s eta 0:01:45
   -- ------------------------------------- 22.4/377.0 MB 3.4 MB/s eta 0:01:46
   -- ------------------------------------- 22.5/377.0 MB 3.3 MB/s eta 0:01:47
   -- ------------------------------------- 22.7/377.0 MB 3.3 MB/s eta 0:01:47
   -- ------------------------------------- 22.9/377.0 MB 3.3 MB/s eta 0:01:47
   -- ------------------------------------- 23.1/377.0 MB 3.3 MB/s eta 0:01:46
   -- ------------------------------------- 23.3/377.0 MB 3.3 MB/s eta 0:01:46
   -- ------------------------------------- 23.5/377.0 MB 3.3 MB/s eta 0:01:47
   -- ------------------------------------- 23.7/377.0 MB 3.3 MB/s eta 0:01:47
   -- ------------------------------------- 23.9/377.0 MB 3.3 MB/s eta 0:01:48
   -- ------------------------------------- 24.2/377.0 MB 3.3 MB/s eta 0:01:48
   -- ------------------------------------- 24.4/377.0 MB 3.3 MB/s eta 0:01:48
   -- ------------------------------------- 24.6/377.0 MB 3.3 MB/s eta 0:01:48
   -- ------------------------------------- 24.8/377.0 MB 3.3 MB/s eta 0:01:46
   -- ------------------------------------- 25.0/377.0 MB 3.3 MB/s eta 0:01:47
   -- ------------------------------------- 25.2/377.0 MB 3.3 MB/s eta 0:01:47
   -- ------------------------------------- 25.5/377.0 MB 3.3 MB/s eta 0:01:47
   -- ------------------------------------- 25.7/377.0 MB 3.3 MB/s eta 0:01:47
   -- ------------------------------------- 25.9/377.0 MB 3.3 MB/s eta 0:01:46
   -- ------------------------------------- 26.2/377.0 MB 3.3 MB/s eta 0:01:46
   -- ------------------------------------- 26.2/377.0 MB 3.4 MB/s eta 0:01:45
   -- ------------------------------------- 26.4/377.0 MB 3.3 MB/s eta 0:01:46
   -- ------------------------------------- 26.4/377.0 MB 3.3 MB/s eta 0:01:46
   -- ------------------------------------- 26.5/377.0 MB 3.3 MB/s eta 0:01:48
   -- ------------------------------------- 26.6/377.0 MB 3.2 MB/s eta 0:01:49
   -- ------------------------------------- 26.7/377.0 MB 3.2 MB/s eta 0:01:50
   -- ------------------------------------- 26.7/377.0 MB 3.2 MB/s eta 0:01:51
   -- ------------------------------------- 26.8/377.0 MB 3.2 MB/s eta 0:01:51
   -- ------------------------------------- 26.9/377.0 MB 3.1 MB/s eta 0:01:52
   -- ------------------------------------- 27.0/377.0 MB 3.1 MB/s eta 0:01:53
   -- ------------------------------------- 27.1/377.0 MB 3.1 MB/s eta 0:01:55
   -- ------------------------------------- 27.3/377.0 MB 3.0 MB/s eta 0:01:55
   -- ------------------------------------- 27.4/377.0 MB 3.0 MB/s eta 0:01:56
   -- ------------------------------------- 27.5/377.0 MB 3.0 MB/s eta 0:01:57
   -- ------------------------------------- 27.6/377.0 MB 3.0 MB/s eta 0:01:57
   -- ------------------------------------- 27.7/377.0 MB 3.0 MB/s eta 0:01:58
   -- ------------------------------------- 27.8/377.0 MB 2.9 MB/s eta 0:01:59
   -- ------------------------------------- 27.9/377.0 MB 2.9 MB/s eta 0:02:00
   -- ------------------------------------- 28.0/377.0 MB 2.9 MB/s eta 0:02:01
   -- ------------------------------------- 28.2/377.0 MB 2.9 MB/s eta 0:02:01
   --- ------------------------------------ 28.3/377.0 MB 2.9 MB/s eta 0:02:02
   --- ------------------------------------ 28.5/377.0 MB 2.9 MB/s eta 0:02:02
   --- ------------------------------------ 28.6/377.0 MB 2.9 MB/s eta 0:02:02
   --- ------------------------------------ 28.8/377.0 MB 2.9 MB/s eta 0:02:01
   --- ------------------------------------ 28.9/377.0 MB 2.9 MB/s eta 0:02:02
   --- ------------------------------------ 29.1/377.0 MB 2.9 MB/s eta 0:01:58
   --- ------------------------------------ 29.2/377.0 MB 3.0 MB/s eta 0:01:57
   --- ------------------------------------ 29.4/377.0 MB 3.0 MB/s eta 0:01:55
   --- ------------------------------------ 29.6/377.0 MB 3.1 MB/s eta 0:01:53
   --- ------------------------------------ 29.7/377.0 MB 3.2 MB/s eta 0:01:50
   --- ------------------------------------ 29.9/377.0 MB 3.2 MB/s eta 0:01:49
   --- ------------------------------------ 30.0/377.0 MB 3.2 MB/s eta 0:01:48
   --- ------------------------------------ 30.2/377.0 MB 3.3 MB/s eta 0:01:47
   --- ------------------------------------ 30.4/377.0 MB 3.3 MB/s eta 0:01:46
   --- ------------------------------------ 30.6/377.0 MB 3.3 MB/s eta 0:01:45
   --- ------------------------------------ 30.8/377.0 MB 3.3 MB/s eta 0:01:44
   --- ------------------------------------ 30.9/377.0 MB 3.4 MB/s eta 0:01:44
   --- ------------------------------------ 31.1/377.0 MB 3.4 MB/s eta 0:01:42
   --- ------------------------------------ 31.4/377.0 MB 3.4 MB/s eta 0:01:41
   --- ------------------------------------ 31.5/377.0 MB 3.4 MB/s eta 0:01:41
   --- ------------------------------------ 31.8/377.0 MB 3.4 MB/s eta 0:01:41
   --- ------------------------------------ 32.0/377.0 MB 3.5 MB/s eta 0:01:40
   --- ------------------------------------ 32.2/377.0 MB 3.5 MB/s eta 0:01:40
   --- ------------------------------------ 32.5/377.0 MB 3.5 MB/s eta 0:01:39
   --- ------------------------------------ 32.7/377.0 MB 3.6 MB/s eta 0:01:37
   --- ------------------------------------ 32.9/377.0 MB 3.6 MB/s eta 0:01:37
   --- ------------------------------------ 33.1/377.0 MB 3.6 MB/s eta 0:01:36
   --- ------------------------------------ 33.4/377.0 MB 3.6 MB/s eta 0:01:36
   --- ------------------------------------ 33.6/377.0 MB 3.6 MB/s eta 0:01:35
   --- ------------------------------------ 33.8/377.0 MB 3.6 MB/s eta 0:01:35
   --- ------------------------------------ 34.0/377.0 MB 3.6 MB/s eta 0:01:35
   --- ------------------------------------ 34.3/377.0 MB 3.7 MB/s eta 0:01:34
   --- ------------------------------------ 34.4/377.0 MB 3.6 MB/s eta 0:01:35
   --- ------------------------------------ 34.4/377.0 MB 3.6 MB/s eta 0:01:35
   --- ------------------------------------ 34.6/377.0 MB 3.6 MB/s eta 0:01:36
   --- ------------------------------------ 34.7/377.0 MB 3.6 MB/s eta 0:01:37
   --- ------------------------------------ 34.8/377.0 MB 3.5 MB/s eta 0:01:38
   --- ------------------------------------ 34.9/377.0 MB 3.5 MB/s eta 0:01:38
   --- ------------------------------------ 35.0/377.0 MB 3.4 MB/s eta 0:01:40
   --- ------------------------------------ 35.2/377.0 MB 3.4 MB/s eta 0:01:40
   --- ------------------------------------ 35.3/377.0 MB 3.4 MB/s eta 0:01:41
   --- ------------------------------------ 35.5/377.0 MB 3.4 MB/s eta 0:01:41
   --- ------------------------------------ 35.6/377.0 MB 3.4 MB/s eta 0:01:41
   --- ------------------------------------ 35.8/377.0 MB 3.4 MB/s eta 0:01:42
   --- ------------------------------------ 35.9/377.0 MB 3.3 MB/s eta 0:01:43
   --- ------------------------------------ 36.1/377.0 MB 3.3 MB/s eta 0:01:43
   --- ------------------------------------ 36.2/377.0 MB 3.3 MB/s eta 0:01:43
   --- ------------------------------------ 36.4/377.0 MB 3.3 MB/s eta 0:01:44
   --- ------------------------------------ 36.6/377.0 MB 3.3 MB/s eta 0:01:43
   --- ------------------------------------ 36.8/377.0 MB 3.4 MB/s eta 0:01:41
   --- ------------------------------------ 37.0/377.0 MB 3.4 MB/s eta 0:01:39
   --- ------------------------------------ 37.1/377.0 MB 3.5 MB/s eta 0:01:38
   --- ------------------------------------ 37.3/377.0 MB 3.5 MB/s eta 0:01:37
   --- ------------------------------------ 37.4/377.0 MB 3.5 MB/s eta 0:01:36
   --- ------------------------------------ 37.6/377.0 MB 3.6 MB/s eta 0:01:35
   ---- ----------------------------------- 37.8/377.0 MB 3.6 MB/s eta 0:01:34
   ---- ----------------------------------- 38.0/377.0 MB 3.7 MB/s eta 0:01:32
   ---- ----------------------------------- 38.1/377.0 MB 3.7 MB/s eta 0:01:33
   ---- ----------------------------------- 38.2/377.0 MB 3.7 MB/s eta 0:01:32
   ---- ----------------------------------- 38.5/377.0 MB 3.7 MB/s eta 0:01:31
   ---- ----------------------------------- 38.6/377.0 MB 3.7 MB/s eta 0:01:31
   ---- ----------------------------------- 38.9/377.0 MB 3.8 MB/s eta 0:01:30
   ---- ----------------------------------- 39.1/377.0 MB 3.8 MB/s eta 0:01:29
   ---- ----------------------------------- 39.4/377.0 MB 3.8 MB/s eta 0:01:29
   ---- ----------------------------------- 39.5/377.0 MB 3.8 MB/s eta 0:01:29
   ---- ----------------------------------- 39.7/377.0 MB 3.9 MB/s eta 0:01:28
   ---- ----------------------------------- 39.9/377.0 MB 3.9 MB/s eta 0:01:28
   ---- ----------------------------------- 40.1/377.0 MB 3.9 MB/s eta 0:01:27
   ---- ----------------------------------- 40.4/377.0 MB 3.9 MB/s eta 0:01:26
   ---- ----------------------------------- 40.6/377.0 MB 3.9 MB/s eta 0:01:26
   ---- ----------------------------------- 40.8/377.0 MB 4.0 MB/s eta 0:01:25
   ---- ----------------------------------- 41.0/377.0 MB 4.0 MB/s eta 0:01:25
   ---- ----------------------------------- 41.3/377.0 MB 4.0 MB/s eta 0:01:25
   ---- ----------------------------------- 41.4/377.0 MB 4.0 MB/s eta 0:01:25
   ---- ----------------------------------- 41.7/377.0 MB 4.0 MB/s eta 0:01:24
   ---- ----------------------------------- 42.0/377.0 MB 4.0 MB/s eta 0:01:24
   ---- ----------------------------------- 42.3/377.0 MB 4.0 MB/s eta 0:01:24
   ---- ----------------------------------- 42.5/377.0 MB 4.0 MB/s eta 0:01:24
   ---- ----------------------------------- 42.7/377.0 MB 4.0 MB/s eta 0:01:24
   ---- ----------------------------------- 42.9/377.0 MB 4.0 MB/s eta 0:01:24
   ---- ----------------------------------- 43.2/377.0 MB 4.0 MB/s eta 0:01:24
   ---- ----------------------------------- 43.4/377.0 MB 4.0 MB/s eta 0:01:24
   ---- ----------------------------------- 43.6/377.0 MB 4.0 MB/s eta 0:01:23
   ---- ----------------------------------- 43.9/377.0 MB 4.0 MB/s eta 0:01:24
   ---- ----------------------------------- 44.1/377.0 MB 4.0 MB/s eta 0:01:24
   ---- ----------------------------------- 44.2/377.0 MB 4.0 MB/s eta 0:01:23
   ---- ----------------------------------- 44.5/377.0 MB 4.0 MB/s eta 0:01:23
   ---- ----------------------------------- 44.8/377.0 MB 4.1 MB/s eta 0:01:22
   ---- ----------------------------------- 45.0/377.0 MB 4.2 MB/s eta 0:01:20
   ---- ----------------------------------- 45.2/377.0 MB 4.3 MB/s eta 0:01:19
   ---- ----------------------------------- 45.4/377.0 MB 4.3 MB/s eta 0:01:17
   ---- ----------------------------------- 45.7/377.0 MB 4.4 MB/s eta 0:01:16
   ---- ----------------------------------- 45.9/377.0 MB 4.4 MB/s eta 0:01:15
   ---- ----------------------------------- 46.2/377.0 MB 4.5 MB/s eta 0:01:14
   ---- ----------------------------------- 46.4/377.0 MB 4.5 MB/s eta 0:01:14
   ---- ----------------------------------- 46.6/377.0 MB 4.5 MB/s eta 0:01:14
   ---- ----------------------------------- 46.8/377.0 MB 4.5 MB/s eta 0:01:13
   ---- ----------------------------------- 47.0/377.0 MB 4.6 MB/s eta 0:01:13
   ----- ---------------------------------- 47.2/377.0 MB 4.6 MB/s eta 0:01:12
   ----- ---------------------------------- 47.4/377.0 MB 4.7 MB/s eta 0:01:11
   ----- ---------------------------------- 47.7/377.0 MB 4.7 MB/s eta 0:01:11
   ----- ---------------------------------- 47.9/377.0 MB 4.7 MB/s eta 0:01:10
   ----- ---------------------------------- 48.1/377.0 MB 4.7 MB/s eta 0:01:10
   ----- ---------------------------------- 48.3/377.0 MB 4.8 MB/s eta 0:01:09
   ----- ---------------------------------- 48.6/377.0 MB 4.8 MB/s eta 0:01:08
   ----- ---------------------------------- 48.8/377.0 MB 4.8 MB/s eta 0:01:08
   ----- ---------------------------------- 49.0/377.0 MB 4.8 MB/s eta 0:01:09
   ----- ---------------------------------- 49.2/377.0 MB 4.8 MB/s eta 0:01:09
   ----- ---------------------------------- 49.4/377.0 MB 4.8 MB/s eta 0:01:09
   ----- ---------------------------------- 49.7/377.0 MB 4.8 MB/s eta 0:01:08
   ----- ---------------------------------- 49.7/377.0 MB 4.8 MB/s eta 0:01:08
   ----- ---------------------------------- 50.0/377.0 MB 4.8 MB/s eta 0:01:08
   ----- ---------------------------------- 50.2/377.0 MB 4.8 MB/s eta 0:01:09
   ----- ---------------------------------- 50.3/377.0 MB 4.8 MB/s eta 0:01:09
   ----- ---------------------------------- 50.4/377.0 MB 4.7 MB/s eta 0:01:10
   ----- ---------------------------------- 50.5/377.0 MB 4.6 MB/s eta 0:01:11
   ----- ---------------------------------- 50.6/377.0 MB 4.6 MB/s eta 0:01:11
   ----- ---------------------------------- 50.8/377.0 MB 4.6 MB/s eta 0:01:12
   ----- ---------------------------------- 50.9/377.0 MB 4.5 MB/s eta 0:01:13
   ----- ---------------------------------- 51.1/377.0 MB 4.5 MB/s eta 0:01:13
   ----- ---------------------------------- 51.3/377.0 MB 4.5 MB/s eta 0:01:14
   ----- ---------------------------------- 51.4/377.0 MB 4.4 MB/s eta 0:01:14
   ----- ---------------------------------- 51.5/377.0 MB 4.4 MB/s eta 0:01:15
   ----- ---------------------------------- 51.7/377.0 MB 4.4 MB/s eta 0:01:15
   ----- ---------------------------------- 51.9/377.0 MB 4.4 MB/s eta 0:01:15
   ----- ---------------------------------- 52.1/377.0 MB 4.3 MB/s eta 0:01:15
   ----- ---------------------------------- 52.2/377.0 MB 4.3 MB/s eta 0:01:16
   ----- ---------------------------------- 52.4/377.0 MB 4.3 MB/s eta 0:01:16
   ----- ---------------------------------- 52.4/377.0 MB 4.2 MB/s eta 0:01:17
   ----- ---------------------------------- 52.6/377.0 MB 4.2 MB/s eta 0:01:18
   ----- ---------------------------------- 52.8/377.0 MB 4.2 MB/s eta 0:01:18
   ----- ---------------------------------- 53.0/377.0 MB 4.1 MB/s eta 0:01:19
   ----- ---------------------------------- 53.2/377.0 MB 4.1 MB/s eta 0:01:19
   ----- ---------------------------------- 53.4/377.0 MB 4.1 MB/s eta 0:01:19
   ----- ---------------------------------- 53.6/377.0 MB 4.1 MB/s eta 0:01:19
   ----- ---------------------------------- 53.8/377.0 MB 4.1 MB/s eta 0:01:18
   ----- ---------------------------------- 54.1/377.0 MB 4.1 MB/s eta 0:01:18
   ----- ---------------------------------- 54.3/377.0 MB 4.1 MB/s eta 0:01:19
   ----- ---------------------------------- 54.5/377.0 MB 4.1 MB/s eta 0:01:18
   ----- ---------------------------------- 54.7/377.0 MB 4.1 MB/s eta 0:01:19
   ----- ---------------------------------- 55.0/377.0 MB 4.1 MB/s eta 0:01:19
   ----- ---------------------------------- 55.2/377.0 MB 4.1 MB/s eta 0:01:19
   ----- ---------------------------------- 55.4/377.0 MB 4.1 MB/s eta 0:01:19
   ----- ---------------------------------- 55.6/377.0 MB 4.1 MB/s eta 0:01:19
   ----- ---------------------------------- 55.9/377.0 MB 4.1 MB/s eta 0:01:18
   ----- ---------------------------------- 56.1/377.0 MB 4.1 MB/s eta 0:01:18
   ----- ---------------------------------- 56.3/377.0 MB 4.1 MB/s eta 0:01:18
   ------ --------------------------------- 56.6/377.0 MB 4.1 MB/s eta 0:01:18
   ------ --------------------------------- 56.9/377.0 MB 4.1 MB/s eta 0:01:18
   ------ --------------------------------- 57.0/377.0 MB 4.1 MB/s eta 0:01:18
   ------ --------------------------------- 57.3/377.0 MB 4.1 MB/s eta 0:01:18
   ------ --------------------------------- 57.4/377.0 MB 4.1 MB/s eta 0:01:18
   ------ --------------------------------- 57.5/377.0 MB 4.1 MB/s eta 0:01:19
   ------ --------------------------------- 57.7/377.0 MB 4.1 MB/s eta 0:01:18
   ------ --------------------------------- 58.0/377.0 MB 4.1 MB/s eta 0:01:18
   ------ --------------------------------- 58.3/377.0 MB 4.1 MB/s eta 0:01:18
   ------ --------------------------------- 58.4/377.0 MB 4.1 MB/s eta 0:01:18
   ------ --------------------------------- 58.7/377.0 MB 4.1 MB/s eta 0:01:18
   ------ --------------------------------- 58.9/377.0 MB 4.1 MB/s eta 0:01:18
   ------ --------------------------------- 59.0/377.0 MB 4.1 MB/s eta 0:01:18
   ------ --------------------------------- 59.3/377.0 MB 4.1 MB/s eta 0:01:18
   ------ --------------------------------- 59.5/377.0 MB 4.1 MB/s eta 0:01:18
   ------ --------------------------------- 59.5/377.0 MB 4.0 MB/s eta 0:01:19
   ------ --------------------------------- 59.6/377.0 MB 4.0 MB/s eta 0:01:19
   ------ --------------------------------- 59.8/377.0 MB 4.0 MB/s eta 0:01:20
   ------ --------------------------------- 59.9/377.0 MB 4.0 MB/s eta 0:01:20
   ------ --------------------------------- 60.0/377.0 MB 4.0 MB/s eta 0:01:20
   ------ --------------------------------- 60.2/377.0 MB 3.9 MB/s eta 0:01:21
   ------ --------------------------------- 60.2/377.0 MB 3.9 MB/s eta 0:01:21
   ------ --------------------------------- 60.4/377.0 MB 3.9 MB/s eta 0:01:21
   ------ --------------------------------- 60.5/377.0 MB 3.9 MB/s eta 0:01:22
   ------ --------------------------------- 60.6/377.0 MB 3.9 MB/s eta 0:01:22
   ------ --------------------------------- 60.7/377.0 MB 3.9 MB/s eta 0:01:22
   ------ --------------------------------- 60.8/377.0 MB 3.9 MB/s eta 0:01:22
   ------ --------------------------------- 60.9/377.0 MB 3.9 MB/s eta 0:01:21
   ------ --------------------------------- 61.1/377.0 MB 3.9 MB/s eta 0:01:21
   ------ --------------------------------- 61.2/377.0 MB 3.9 MB/s eta 0:01:21
   ------ --------------------------------- 61.3/377.0 MB 3.9 MB/s eta 0:01:22
   ------ --------------------------------- 61.4/377.0 MB 3.9 MB/s eta 0:01:22
   ------ --------------------------------- 61.6/377.0 MB 3.9 MB/s eta 0:01:21
   ------ --------------------------------- 61.7/377.0 MB 3.9 MB/s eta 0:01:22
   ------ --------------------------------- 61.9/377.0 MB 3.9 MB/s eta 0:01:22
   ------ --------------------------------- 62.0/377.0 MB 3.9 MB/s eta 0:01:22
   ------ --------------------------------- 62.2/377.0 MB 3.9 MB/s eta 0:01:22
   ------ --------------------------------- 62.3/377.0 MB 3.9 MB/s eta 0:01:22
   ------ --------------------------------- 62.5/377.0 MB 3.9 MB/s eta 0:01:22
   ------ --------------------------------- 62.6/377.0 MB 3.9 MB/s eta 0:01:21
   ------ --------------------------------- 62.8/377.0 MB 3.9 MB/s eta 0:01:21
   ------ --------------------------------- 62.9/377.0 MB 3.9 MB/s eta 0:01:21
   ------ --------------------------------- 63.1/377.0 MB 3.9 MB/s eta 0:01:22
   ------ --------------------------------- 63.3/377.0 MB 3.9 MB/s eta 0:01:21
   ------ --------------------------------- 63.4/377.0 MB 3.9 MB/s eta 0:01:21
   ------ --------------------------------- 63.6/377.0 MB 3.9 MB/s eta 0:01:21
   ------ --------------------------------- 63.7/377.0 MB 3.9 MB/s eta 0:01:21
   ------ --------------------------------- 63.9/377.0 MB 3.9 MB/s eta 0:01:22
   ------ --------------------------------- 64.1/377.0 MB 3.9 MB/s eta 0:01:22
   ------ --------------------------------- 64.3/377.0 MB 3.9 MB/s eta 0:01:21
   ------ --------------------------------- 64.6/377.0 MB 3.9 MB/s eta 0:01:22
   ------ --------------------------------- 64.7/377.0 MB 3.9 MB/s eta 0:01:21
   ------ --------------------------------- 64.9/377.0 MB 3.9 MB/s eta 0:01:22
   ------ --------------------------------- 65.1/377.0 MB 3.9 MB/s eta 0:01:21
   ------ --------------------------------- 65.3/377.0 MB 3.9 MB/s eta 0:01:21
   ------ --------------------------------- 65.5/377.0 MB 3.9 MB/s eta 0:01:21
   ------ --------------------------------- 65.7/377.0 MB 3.9 MB/s eta 0:01:21
   ------- -------------------------------- 66.0/377.0 MB 3.9 MB/s eta 0:01:21
   ------- -------------------------------- 66.2/377.0 MB 3.9 MB/s eta 0:01:21
   ------- -------------------------------- 66.4/377.0 MB 3.9 MB/s eta 0:01:21
   ------- -------------------------------- 66.6/377.0 MB 3.9 MB/s eta 0:01:21
   ------- -------------------------------- 66.8/377.0 MB 3.9 MB/s eta 0:01:21
   ------- -------------------------------- 67.1/377.0 MB 3.9 MB/s eta 0:01:21
   ------- -------------------------------- 67.3/377.0 MB 3.9 MB/s eta 0:01:21
   ------- -------------------------------- 67.5/377.0 MB 3.9 MB/s eta 0:01:21
   ------- -------------------------------- 67.7/377.0 MB 3.9 MB/s eta 0:01:20
   ------- -------------------------------- 67.9/377.0 MB 3.9 MB/s eta 0:01:20
   ------- -------------------------------- 68.0/377.0 MB 3.9 MB/s eta 0:01:20
   ------- -------------------------------- 68.2/377.0 MB 3.9 MB/s eta 0:01:20
   ------- -------------------------------- 68.4/377.0 MB 3.9 MB/s eta 0:01:20
   ------- -------------------------------- 68.6/377.0 MB 3.9 MB/s eta 0:01:20
   ------- -------------------------------- 68.8/377.0 MB 3.9 MB/s eta 0:01:20
   ------- -------------------------------- 68.9/377.0 MB 3.9 MB/s eta 0:01:20
   ------- -------------------------------- 69.1/377.0 MB 3.9 MB/s eta 0:01:19
   ------- -------------------------------- 69.3/377.0 MB 3.9 MB/s eta 0:01:20
   ------- -------------------------------- 69.4/377.0 MB 3.9 MB/s eta 0:01:20
   ------- -------------------------------- 69.5/377.0 MB 3.9 MB/s eta 0:01:20
   ------- -------------------------------- 69.7/377.0 MB 3.9 MB/s eta 0:01:19
   ------- -------------------------------- 69.9/377.0 MB 3.9 MB/s eta 0:01:19
   ------- -------------------------------- 70.2/377.0 MB 4.0 MB/s eta 0:01:18
   ------- -------------------------------- 70.4/377.0 MB 4.0 MB/s eta 0:01:18
   ------- -------------------------------- 70.5/377.0 MB 4.0 MB/s eta 0:01:17
   ------- -------------------------------- 70.5/377.0 MB 4.0 MB/s eta 0:01:18
   ------- -------------------------------- 70.7/377.0 MB 4.0 MB/s eta 0:01:17
   ------- -------------------------------- 70.8/377.0 MB 4.0 MB/s eta 0:01:18
   ------- -------------------------------- 70.9/377.0 MB 4.0 MB/s eta 0:01:17
   ------- -------------------------------- 71.0/377.0 MB 4.0 MB/s eta 0:01:17
   ------- -------------------------------- 71.1/377.0 MB 4.0 MB/s eta 0:01:18
   ------- -------------------------------- 71.2/377.0 MB 3.9 MB/s eta 0:01:19
   ------- -------------------------------- 71.3/377.0 MB 3.9 MB/s eta 0:01:19
   ------- -------------------------------- 71.3/377.0 MB 3.9 MB/s eta 0:01:19
   ------- -------------------------------- 71.4/377.0 MB 3.9 MB/s eta 0:01:20
   ------- -------------------------------- 71.5/377.0 MB 3.9 MB/s eta 0:01:20
   ------- -------------------------------- 71.6/377.0 MB 3.8 MB/s eta 0:01:20
   ------- -------------------------------- 71.6/377.0 MB 3.8 MB/s eta 0:01:21
   ------- -------------------------------- 71.7/377.0 MB 3.8 MB/s eta 0:01:21
   ------- -------------------------------- 71.8/377.0 MB 3.8 MB/s eta 0:01:22
   ------- -------------------------------- 71.9/377.0 MB 3.8 MB/s eta 0:01:22
   ------- -------------------------------- 72.0/377.0 MB 3.7 MB/s eta 0:01:22
   ------- -------------------------------- 72.1/377.0 MB 3.7 MB/s eta 0:01:22
   ------- -------------------------------- 72.2/377.0 MB 3.7 MB/s eta 0:01:23
   ------- -------------------------------- 72.3/377.0 MB 3.7 MB/s eta 0:01:23
   ------- -------------------------------- 72.4/377.0 MB 3.7 MB/s eta 0:01:23
   ------- -------------------------------- 72.5/377.0 MB 3.7 MB/s eta 0:01:23
   ------- -------------------------------- 72.7/377.0 MB 3.7 MB/s eta 0:01:23
   ------- -------------------------------- 72.8/377.0 MB 3.7 MB/s eta 0:01:24
   ------- -------------------------------- 73.0/377.0 MB 3.6 MB/s eta 0:01:24
   ------- -------------------------------- 73.0/377.0 MB 3.6 MB/s eta 0:01:24
   ------- -------------------------------- 73.0/377.0 MB 3.6 MB/s eta 0:01:25
   ------- -------------------------------- 73.2/377.0 MB 3.5 MB/s eta 0:01:26
   ------- -------------------------------- 73.4/377.0 MB 3.5 MB/s eta 0:01:26
   ------- -------------------------------- 73.5/377.0 MB 3.5 MB/s eta 0:01:27
   ------- -------------------------------- 73.7/377.0 MB 3.5 MB/s eta 0:01:27
   ------- -------------------------------- 73.8/377.0 MB 3.5 MB/s eta 0:01:26
   ------- -------------------------------- 73.9/377.0 MB 3.5 MB/s eta 0:01:27
   ------- -------------------------------- 74.1/377.0 MB 3.5 MB/s eta 0:01:27
   ------- -------------------------------- 74.3/377.0 MB 3.5 MB/s eta 0:01:26
   ------- -------------------------------- 74.5/377.0 MB 3.5 MB/s eta 0:01:27
   ------- -------------------------------- 74.6/377.0 MB 3.5 MB/s eta 0:01:28
   ------- -------------------------------- 74.8/377.0 MB 3.5 MB/s eta 0:01:28
   ------- -------------------------------- 74.9/377.0 MB 3.5 MB/s eta 0:01:28
   ------- -------------------------------- 75.1/377.0 MB 3.4 MB/s eta 0:01:28
   ------- -------------------------------- 75.3/377.0 MB 3.4 MB/s eta 0:01:28
   -------- ------------------------------- 75.5/377.0 MB 3.5 MB/s eta 0:01:28
   -------- ------------------------------- 75.7/377.0 MB 3.4 MB/s eta 0:01:28
   -------- ------------------------------- 75.9/377.0 MB 3.4 MB/s eta 0:01:28
   -------- ------------------------------- 76.1/377.0 MB 3.4 MB/s eta 0:01:28
   -------- ------------------------------- 76.3/377.0 MB 3.4 MB/s eta 0:01:29
   -------- ------------------------------- 76.6/377.0 MB 3.4 MB/s eta 0:01:28
   -------- ------------------------------- 76.7/377.0 MB 3.4 MB/s eta 0:01:28
   -------- ------------------------------- 76.9/377.0 MB 3.4 MB/s eta 0:01:28
   -------- ------------------------------- 77.1/377.0 MB 3.4 MB/s eta 0:01:28
   -------- ------------------------------- 77.3/377.0 MB 3.4 MB/s eta 0:01:28
   -------- ------------------------------- 77.4/377.0 MB 3.4 MB/s eta 0:01:28
   -------- ------------------------------- 77.7/377.0 MB 3.4 MB/s eta 0:01:28
   -------- ------------------------------- 77.9/377.0 MB 3.4 MB/s eta 0:01:29
   -------- ------------------------------- 78.1/377.0 MB 3.4 MB/s eta 0:01:28
   -------- ------------------------------- 78.4/377.0 MB 3.4 MB/s eta 0:01:28
   -------- ------------------------------- 78.6/377.0 MB 3.4 MB/s eta 0:01:28
   -------- ------------------------------- 78.9/377.0 MB 3.4 MB/s eta 0:01:27
   -------- ------------------------------- 79.1/377.0 MB 3.4 MB/s eta 0:01:27
   -------- ------------------------------- 79.2/377.0 MB 3.4 MB/s eta 0:01:28
   -------- ------------------------------- 79.4/377.0 MB 3.4 MB/s eta 0:01:28
   -------- ------------------------------- 79.5/377.0 MB 3.4 MB/s eta 0:01:28
   -------- ------------------------------- 79.6/377.0 MB 3.4 MB/s eta 0:01:29
   -------- ------------------------------- 79.7/377.0 MB 3.3 MB/s eta 0:01:30
   -------- ------------------------------- 79.7/377.0 MB 3.3 MB/s eta 0:01:29
   -------- ------------------------------- 79.8/377.0 MB 3.3 MB/s eta 0:01:31
   -------- ------------------------------- 79.9/377.0 MB 3.3 MB/s eta 0:01:31
   -------- ------------------------------- 79.9/377.0 MB 3.2 MB/s eta 0:01:33
   -------- ------------------------------- 80.0/377.0 MB 3.2 MB/s eta 0:01:34
   -------- ------------------------------- 80.1/377.0 MB 3.2 MB/s eta 0:01:34
   -------- ------------------------------- 80.2/377.0 MB 3.1 MB/s eta 0:01:35
   -------- ------------------------------- 80.3/377.0 MB 3.1 MB/s eta 0:01:36
   -------- ------------------------------- 80.4/377.0 MB 3.1 MB/s eta 0:01:37
   -------- ------------------------------- 80.4/377.0 MB 3.1 MB/s eta 0:01:37
   -------- ------------------------------- 80.5/377.0 MB 3.0 MB/s eta 0:01:38
   -------- ------------------------------- 80.7/377.0 MB 3.0 MB/s eta 0:01:39
   -------- ------------------------------- 80.8/377.0 MB 3.0 MB/s eta 0:01:38
   -------- ------------------------------- 80.9/377.0 MB 3.0 MB/s eta 0:01:39
   -------- ------------------------------- 81.0/377.0 MB 3.0 MB/s eta 0:01:38
   -------- ------------------------------- 81.1/377.0 MB 3.0 MB/s eta 0:01:39
   -------- ------------------------------- 81.2/377.0 MB 3.0 MB/s eta 0:01:39
   -------- ------------------------------- 81.3/377.0 MB 3.0 MB/s eta 0:01:38
   -------- ------------------------------- 81.5/377.0 MB 3.0 MB/s eta 0:01:38
   -------- ------------------------------- 81.6/377.0 MB 3.1 MB/s eta 0:01:37
   -------- ------------------------------- 81.7/377.0 MB 3.1 MB/s eta 0:01:36
   -------- ------------------------------- 81.9/377.0 MB 3.1 MB/s eta 0:01:35
   -------- ------------------------------- 82.1/377.0 MB 3.2 MB/s eta 0:01:34
   -------- ------------------------------- 82.2/377.0 MB 3.2 MB/s eta 0:01:33
   -------- ------------------------------- 82.4/377.0 MB 3.2 MB/s eta 0:01:32
   -------- ------------------------------- 82.6/377.0 MB 3.2 MB/s eta 0:01:32
   -------- ------------------------------- 82.7/377.0 MB 3.2 MB/s eta 0:01:32
   -------- ------------------------------- 82.9/377.0 MB 3.2 MB/s eta 0:01:31
   -------- ------------------------------- 83.1/377.0 MB 3.3 MB/s eta 0:01:31
   -------- ------------------------------- 83.3/377.0 MB 3.3 MB/s eta 0:01:29
   -------- ------------------------------- 83.4/377.0 MB 3.3 MB/s eta 0:01:28
   -------- ------------------------------- 83.6/377.0 MB 3.4 MB/s eta 0:01:28
   -------- ------------------------------- 83.8/377.0 MB 3.4 MB/s eta 0:01:27
   -------- ------------------------------- 83.9/377.0 MB 3.4 MB/s eta 0:01:28
   -------- ------------------------------- 84.0/377.0 MB 3.3 MB/s eta 0:01:29
   -------- ------------------------------- 84.2/377.0 MB 3.3 MB/s eta 0:01:29
   -------- ------------------------------- 84.4/377.0 MB 3.4 MB/s eta 0:01:28
   -------- ------------------------------- 84.6/377.0 MB 3.4 MB/s eta 0:01:28
   --------- ------------------------------ 84.8/377.0 MB 3.4 MB/s eta 0:01:27
   --------- ------------------------------ 85.1/377.0 MB 3.4 MB/s eta 0:01:27
   --------- ------------------------------ 85.3/377.0 MB 3.4 MB/s eta 0:01:27
   --------- ------------------------------ 85.5/377.0 MB 3.4 MB/s eta 0:01:26
   --------- ------------------------------ 85.8/377.0 MB 3.4 MB/s eta 0:01:26
   --------- ------------------------------ 86.0/377.0 MB 3.4 MB/s eta 0:01:26
   --------- ------------------------------ 86.2/377.0 MB 3.4 MB/s eta 0:01:26
   --------- ------------------------------ 86.4/377.0 MB 3.4 MB/s eta 0:01:26
   --------- ------------------------------ 86.7/377.0 MB 3.4 MB/s eta 0:01:26
   --------- ------------------------------ 86.9/377.0 MB 3.4 MB/s eta 0:01:26
   --------- ------------------------------ 87.1/377.0 MB 3.4 MB/s eta 0:01:25
   --------- ------------------------------ 87.3/377.0 MB 3.4 MB/s eta 0:01:25
   --------- ------------------------------ 87.5/377.0 MB 3.4 MB/s eta 0:01:24
   --------- ------------------------------ 87.7/377.0 MB 3.4 MB/s eta 0:01:25
   --------- ------------------------------ 87.9/377.0 MB 3.4 MB/s eta 0:01:25
   --------- ------------------------------ 88.1/377.0 MB 3.5 MB/s eta 0:01:24
   --------- ------------------------------ 88.3/377.0 MB 3.4 MB/s eta 0:01:24
   --------- ------------------------------ 88.5/377.0 MB 3.4 MB/s eta 0:01:24
   --------- ------------------------------ 88.8/377.0 MB 3.4 MB/s eta 0:01:24
   --------- ------------------------------ 88.9/377.0 MB 3.4 MB/s eta 0:01:25
   --------- ------------------------------ 89.0/377.0 MB 3.4 MB/s eta 0:01:25
   --------- ------------------------------ 89.3/377.0 MB 3.4 MB/s eta 0:01:25
   --------- ------------------------------ 89.6/377.0 MB 3.4 MB/s eta 0:01:24
   --------- ------------------------------ 89.8/377.0 MB 3.5 MB/s eta 0:01:23
   --------- ------------------------------ 90.0/377.0 MB 3.6 MB/s eta 0:01:21
   --------- ------------------------------ 90.3/377.0 MB 3.7 MB/s eta 0:01:17
   --------- ------------------------------ 90.5/377.0 MB 3.9 MB/s eta 0:01:14
   --------- ------------------------------ 90.7/377.0 MB 3.9 MB/s eta 0:01:13
   --------- ------------------------------ 90.9/377.0 MB 4.0 MB/s eta 0:01:12
   --------- ------------------------------ 91.1/377.0 MB 4.1 MB/s eta 0:01:11
   --------- ------------------------------ 91.3/377.0 MB 4.2 MB/s eta 0:01:09
   --------- ------------------------------ 91.6/377.0 MB 4.3 MB/s eta 0:01:07
   --------- ------------------------------ 91.8/377.0 MB 4.3 MB/s eta 0:01:07
   --------- ------------------------------ 91.9/377.0 MB 4.3 MB/s eta 0:01:06
   --------- ------------------------------ 92.0/377.0 MB 4.3 MB/s eta 0:01:06
   --------- ------------------------------ 92.1/377.0 MB 4.3 MB/s eta 0:01:07
   --------- ------------------------------ 92.3/377.0 MB 4.3 MB/s eta 0:01:06
   --------- ------------------------------ 92.4/377.0 MB 4.3 MB/s eta 0:01:07
   --------- ------------------------------ 92.5/377.0 MB 4.2 MB/s eta 0:01:08
   --------- ------------------------------ 92.6/377.0 MB 4.2 MB/s eta 0:01:08
   --------- ------------------------------ 92.7/377.0 MB 4.2 MB/s eta 0:01:08
   --------- ------------------------------ 92.8/377.0 MB 4.2 MB/s eta 0:01:08
   --------- ------------------------------ 92.9/377.0 MB 4.1 MB/s eta 0:01:09
   --------- ------------------------------ 93.0/377.0 MB 4.2 MB/s eta 0:01:09
   --------- ------------------------------ 93.1/377.0 MB 4.1 MB/s eta 0:01:09
   --------- ------------------------------ 93.1/377.0 MB 4.1 MB/s eta 0:01:10
   --------- ------------------------------ 93.3/377.0 MB 4.0 MB/s eta 0:01:11
   --------- ------------------------------ 93.4/377.0 MB 4.0 MB/s eta 0:01:11
   --------- ------------------------------ 93.5/377.0 MB 4.0 MB/s eta 0:01:11
   --------- ------------------------------ 93.6/377.0 MB 4.0 MB/s eta 0:01:11
   --------- ------------------------------ 93.8/377.0 MB 4.0 MB/s eta 0:01:12
   --------- ------------------------------ 94.0/377.0 MB 4.0 MB/s eta 0:01:12
   --------- ------------------------------ 94.1/377.0 MB 4.0 MB/s eta 0:01:12
   --------- ------------------------------ 94.2/377.0 MB 4.0 MB/s eta 0:01:11
   ---------- ----------------------------- 94.4/377.0 MB 4.0 MB/s eta 0:01:11
   ---------- ----------------------------- 94.6/377.0 MB 4.0 MB/s eta 0:01:11
   ---------- ----------------------------- 94.7/377.0 MB 4.0 MB/s eta 0:01:11
   ---------- ----------------------------- 94.9/377.0 MB 4.0 MB/s eta 0:01:11
   ---------- ----------------------------- 95.0/377.0 MB 4.0 MB/s eta 0:01:12
   ---------- ----------------------------- 95.2/377.0 MB 4.0 MB/s eta 0:01:11
   ---------- ----------------------------- 95.4/377.0 MB 4.0 MB/s eta 0:01:11
   ---------- ----------------------------- 95.6/377.0 MB 3.9 MB/s eta 0:01:12
   ---------- ----------------------------- 95.7/377.0 MB 3.9 MB/s eta 0:01:12
   ---------- ----------------------------- 95.9/377.0 MB 3.9 MB/s eta 0:01:12
   ---------- ----------------------------- 96.1/377.0 MB 3.9 MB/s eta 0:01:12
   ---------- ----------------------------- 96.4/377.0 MB 3.9 MB/s eta 0:01:12
   ---------- ----------------------------- 96.6/377.0 MB 3.9 MB/s eta 0:01:12
   ---------- ----------------------------- 96.7/377.0 MB 3.9 MB/s eta 0:01:12
   ---------- ----------------------------- 96.9/377.0 MB 3.9 MB/s eta 0:01:12
   ---------- ----------------------------- 97.1/377.0 MB 3.9 MB/s eta 0:01:12
   ---------- ----------------------------- 97.3/377.0 MB 3.9 MB/s eta 0:01:12
   ---------- ----------------------------- 97.5/377.0 MB 3.9 MB/s eta 0:01:12
   ---------- ----------------------------- 97.7/377.0 MB 3.9 MB/s eta 0:01:12
   ---------- ----------------------------- 98.0/377.0 MB 3.9 MB/s eta 0:01:12
   ---------- ----------------------------- 98.3/377.0 MB 3.9 MB/s eta 0:01:12
   ---------- ----------------------------- 98.5/377.0 MB 3.9 MB/s eta 0:01:12
   ---------- ----------------------------- 98.8/377.0 MB 3.9 MB/s eta 0:01:11
   ---------- ----------------------------- 98.9/377.0 MB 3.9 MB/s eta 0:01:11
   ---------- ----------------------------- 99.2/377.0 MB 3.9 MB/s eta 0:01:11
   ---------- ----------------------------- 99.4/377.0 MB 4.0 MB/s eta 0:01:10
   ---------- ----------------------------- 99.6/377.0 MB 3.9 MB/s eta 0:01:11
   ---------- ----------------------------- 99.8/377.0 MB 3.9 MB/s eta 0:01:11
   ---------- ----------------------------- 100.0/377.0 MB 3.9 MB/s eta 0:01:11
   ---------- ----------------------------- 100.2/377.0 MB 3.9 MB/s eta 0:01:11
   ---------- ----------------------------- 100.4/377.0 MB 3.9 MB/s eta 0:01:11
   ---------- ----------------------------- 100.6/377.0 MB 3.9 MB/s eta 0:01:11
   ---------- ----------------------------- 100.8/377.0 MB 3.9 MB/s eta 0:01:11
   ---------- ----------------------------- 101.0/377.0 MB 3.9 MB/s eta 0:01:11
   ---------- ----------------------------- 101.1/377.0 MB 3.9 MB/s eta 0:01:11
   ---------- ----------------------------- 101.3/377.0 MB 3.9 MB/s eta 0:01:11
   ---------- ----------------------------- 101.5/377.0 MB 3.9 MB/s eta 0:01:11
   ---------- ----------------------------- 101.7/377.0 MB 3.9 MB/s eta 0:01:11
   ---------- ----------------------------- 101.9/377.0 MB 3.9 MB/s eta 0:01:12
   ---------- ----------------------------- 102.0/377.0 MB 3.9 MB/s eta 0:01:11
   ---------- ----------------------------- 102.2/377.0 MB 3.9 MB/s eta 0:01:12
   ---------- ----------------------------- 102.2/377.0 MB 3.8 MB/s eta 0:01:13
   ---------- ----------------------------- 102.4/377.0 MB 3.9 MB/s eta 0:01:12
   ---------- ----------------------------- 102.7/377.0 MB 3.9 MB/s eta 0:01:10
   ---------- ----------------------------- 102.9/377.0 MB 4.0 MB/s eta 0:01:09
   ---------- ----------------------------- 103.1/377.0 MB 4.1 MB/s eta 0:01:07
   ---------- ----------------------------- 103.4/377.0 MB 4.3 MB/s eta 0:01:05
   ---------- ----------------------------- 103.6/377.0 MB 4.3 MB/s eta 0:01:04
   ----------- ---------------------------- 103.9/377.0 MB 4.4 MB/s eta 0:01:03
   ----------- ---------------------------- 104.1/377.0 MB 4.4 MB/s eta 0:01:03
   ----------- ---------------------------- 104.3/377.0 MB 4.4 MB/s eta 0:01:02
   ----------- ---------------------------- 104.4/377.0 MB 4.5 MB/s eta 0:01:02
   ----------- ---------------------------- 104.7/377.0 MB 4.5 MB/s eta 0:01:01
   ----------- ---------------------------- 104.9/377.0 MB 4.5 MB/s eta 0:01:01
   ----------- ---------------------------- 105.1/377.0 MB 4.5 MB/s eta 0:01:01
   ----------- ---------------------------- 105.3/377.0 MB 4.5 MB/s eta 0:01:00
   ----------- ---------------------------- 105.5/377.0 MB 4.6 MB/s eta 0:01:00
   ----------- ---------------------------- 105.7/377.0 MB 4.6 MB/s eta 0:01:00
   ----------- ---------------------------- 105.8/377.0 MB 4.5 MB/s eta 0:01:01
   ----------- ---------------------------- 105.9/377.0 MB 4.5 MB/s eta 0:01:01
   ----------- ---------------------------- 106.0/377.0 MB 4.5 MB/s eta 0:01:01
   ----------- ---------------------------- 106.2/377.0 MB 4.4 MB/s eta 0:01:02
   ----------- ---------------------------- 106.3/377.0 MB 4.4 MB/s eta 0:01:03
   ----------- ---------------------------- 106.3/377.0 MB 4.3 MB/s eta 0:01:03
   ----------- ---------------------------- 106.4/377.0 MB 4.3 MB/s eta 0:01:04
   ----------- ---------------------------- 106.5/377.0 MB 4.3 MB/s eta 0:01:04
   ----------- ---------------------------- 106.5/377.0 MB 4.2 MB/s eta 0:01:05
   ----------- ---------------------------- 106.6/377.0 MB 4.1 MB/s eta 0:01:06
   ----------- ---------------------------- 106.7/377.0 MB 4.0 MB/s eta 0:01:07
   ----------- ---------------------------- 106.8/377.0 MB 4.0 MB/s eta 0:01:08
   ----------- ---------------------------- 106.9/377.0 MB 4.0 MB/s eta 0:01:08
   ----------- ---------------------------- 107.0/377.0 MB 4.0 MB/s eta 0:01:09
   ----------- ---------------------------- 107.2/377.0 MB 3.9 MB/s eta 0:01:09
   ----------- ---------------------------- 107.3/377.0 MB 3.9 MB/s eta 0:01:09
   ----------- ---------------------------- 107.4/377.0 MB 3.9 MB/s eta 0:01:10
   ----------- ---------------------------- 107.5/377.0 MB 3.9 MB/s eta 0:01:10
   ----------- ---------------------------- 107.7/377.0 MB 3.9 MB/s eta 0:01:10
   ----------- ---------------------------- 107.8/377.0 MB 3.9 MB/s eta 0:01:10
   ----------- ---------------------------- 108.0/377.0 MB 3.8 MB/s eta 0:01:11
   ----------- ---------------------------- 108.1/377.0 MB 3.8 MB/s eta 0:01:12
   ----------- ---------------------------- 108.2/377.0 MB 3.8 MB/s eta 0:01:12
   ----------- ---------------------------- 108.4/377.0 MB 3.8 MB/s eta 0:01:12
   ----------- ---------------------------- 108.6/377.0 MB 3.7 MB/s eta 0:01:13
   ----------- ---------------------------- 108.7/377.0 MB 3.7 MB/s eta 0:01:13
   ----------- ---------------------------- 108.8/377.0 MB 3.7 MB/s eta 0:01:13
   ----------- ---------------------------- 109.0/377.0 MB 3.7 MB/s eta 0:01:13
   ----------- ---------------------------- 109.2/377.0 MB 3.7 MB/s eta 0:01:14
   ----------- ---------------------------- 109.4/377.0 MB 3.7 MB/s eta 0:01:14
   ----------- ---------------------------- 109.5/377.0 MB 3.7 MB/s eta 0:01:14
   ----------- ---------------------------- 109.7/377.0 MB 3.6 MB/s eta 0:01:14
   ----------- ---------------------------- 109.8/377.0 MB 3.6 MB/s eta 0:01:14
   ----------- ---------------------------- 109.9/377.0 MB 3.6 MB/s eta 0:01:15
   ----------- ---------------------------- 110.1/377.0 MB 3.6 MB/s eta 0:01:16
   ----------- ---------------------------- 110.3/377.0 MB 3.6 MB/s eta 0:01:15
   ----------- ---------------------------- 110.5/377.0 MB 3.6 MB/s eta 0:01:15
   ----------- ---------------------------- 110.7/377.0 MB 3.6 MB/s eta 0:01:15
   ----------- ---------------------------- 110.9/377.0 MB 3.6 MB/s eta 0:01:15
   ----------- ---------------------------- 111.1/377.0 MB 3.6 MB/s eta 0:01:15
   ----------- ---------------------------- 111.3/377.0 MB 3.6 MB/s eta 0:01:15
   ----------- ---------------------------- 111.5/377.0 MB 3.6 MB/s eta 0:01:15
   ----------- ---------------------------- 111.7/377.0 MB 3.6 MB/s eta 0:01:14
   ----------- ---------------------------- 111.9/377.0 MB 3.6 MB/s eta 0:01:14
   ----------- ---------------------------- 112.1/377.0 MB 3.6 MB/s eta 0:01:15
   ----------- ---------------------------- 112.4/377.0 MB 3.6 MB/s eta 0:01:13
   ----------- ---------------------------- 112.6/377.0 MB 3.7 MB/s eta 0:01:12
   ----------- ---------------------------- 112.8/377.0 MB 3.7 MB/s eta 0:01:12
   ----------- ---------------------------- 113.1/377.0 MB 3.7 MB/s eta 0:01:13
   ------------ --------------------------- 113.3/377.0 MB 3.7 MB/s eta 0:01:13
   ------------ --------------------------- 113.5/377.0 MB 3.7 MB/s eta 0:01:13
   ------------ --------------------------- 113.7/377.0 MB 3.7 MB/s eta 0:01:12
   ------------ --------------------------- 114.0/377.0 MB 3.7 MB/s eta 0:01:12
   ------------ --------------------------- 114.2/377.0 MB 3.6 MB/s eta 0:01:13
   ------------ --------------------------- 114.2/377.0 MB 3.6 MB/s eta 0:01:13
   ------------ --------------------------- 114.4/377.0 MB 3.6 MB/s eta 0:01:13
   ------------ --------------------------- 114.6/377.0 MB 3.6 MB/s eta 0:01:13
   ------------ --------------------------- 114.6/377.0 MB 3.6 MB/s eta 0:01:14
   ------------ --------------------------- 114.8/377.0 MB 3.5 MB/s eta 0:01:15
   ------------ --------------------------- 115.0/377.0 MB 3.5 MB/s eta 0:01:15
   ------------ --------------------------- 115.1/377.0 MB 3.6 MB/s eta 0:01:14
   ------------ --------------------------- 115.4/377.0 MB 3.6 MB/s eta 0:01:14
   ------------ --------------------------- 115.6/377.0 MB 3.5 MB/s eta 0:01:14
   ------------ --------------------------- 115.8/377.0 MB 3.5 MB/s eta 0:01:14
   ------------ --------------------------- 116.0/377.0 MB 3.5 MB/s eta 0:01:15
   ------------ --------------------------- 116.1/377.0 MB 3.6 MB/s eta 0:01:14
   ------------ --------------------------- 116.3/377.0 MB 3.6 MB/s eta 0:01:13
   ------------ --------------------------- 116.5/377.0 MB 3.7 MB/s eta 0:01:11
   ------------ --------------------------- 116.7/377.0 MB 3.7 MB/s eta 0:01:10
   ------------ --------------------------- 116.9/377.0 MB 3.9 MB/s eta 0:01:06
   ------------ --------------------------- 117.1/377.0 MB 4.0 MB/s eta 0:01:06
   ------------ --------------------------- 117.4/377.0 MB 4.1 MB/s eta 0:01:04
   ------------ --------------------------- 117.6/377.0 MB 4.1 MB/s eta 0:01:04
   ------------ --------------------------- 117.9/377.0 MB 4.2 MB/s eta 0:01:03
   ------------ --------------------------- 118.1/377.0 MB 4.2 MB/s eta 0:01:02
   ------------ --------------------------- 118.4/377.0 MB 4.3 MB/s eta 0:01:01
   ------------ --------------------------- 118.6/377.0 MB 4.3 MB/s eta 0:01:00
   ------------ --------------------------- 118.8/377.0 MB 4.4 MB/s eta 0:01:00
   ------------ --------------------------- 119.1/377.0 MB 4.4 MB/s eta 0:01:00
   ------------ --------------------------- 119.3/377.0 MB 4.4 MB/s eta 0:00:59
   ------------ --------------------------- 119.5/377.0 MB 4.4 MB/s eta 0:00:59
   ------------ --------------------------- 119.6/377.0 MB 4.4 MB/s eta 0:00:59
   ------------ --------------------------- 119.9/377.0 MB 4.4 MB/s eta 0:00:59
   ------------ --------------------------- 120.2/377.0 MB 4.5 MB/s eta 0:00:57
   ------------ --------------------------- 120.4/377.0 MB 4.6 MB/s eta 0:00:57
   ------------ --------------------------- 120.6/377.0 MB 4.6 MB/s eta 0:00:57
   ------------ --------------------------- 120.9/377.0 MB 4.6 MB/s eta 0:00:56
   ------------ --------------------------- 121.1/377.0 MB 4.6 MB/s eta 0:00:56
   ------------ --------------------------- 121.3/377.0 MB 4.6 MB/s eta 0:00:56
   ------------ --------------------------- 121.5/377.0 MB 4.5 MB/s eta 0:00:57
   ------------ --------------------------- 121.7/377.0 MB 4.6 MB/s eta 0:00:56
   ------------ --------------------------- 122.0/377.0 MB 4.6 MB/s eta 0:00:56
   ------------ --------------------------- 122.2/377.0 MB 4.6 MB/s eta 0:00:56
   ------------ --------------------------- 122.4/377.0 MB 4.6 MB/s eta 0:00:56
   ------------- -------------------------- 122.6/377.0 MB 4.6 MB/s eta 0:00:56
   ------------- -------------------------- 122.9/377.0 MB 4.6 MB/s eta 0:00:56
   ------------- -------------------------- 123.1/377.0 MB 4.5 MB/s eta 0:00:57
   ------------- -------------------------- 123.3/377.0 MB 4.5 MB/s eta 0:00:57
   ------------- -------------------------- 123.5/377.0 MB 4.5 MB/s eta 0:00:56
   ------------- -------------------------- 123.8/377.0 MB 4.5 MB/s eta 0:00:56
   ------------- -------------------------- 124.0/377.0 MB 4.5 MB/s eta 0:00:56
   ------------- -------------------------- 124.3/377.0 MB 4.5 MB/s eta 0:00:56
   ------------- -------------------------- 124.5/377.0 MB 4.6 MB/s eta 0:00:55
   ------------- -------------------------- 124.7/377.0 MB 4.7 MB/s eta 0:00:54
   ------------- -------------------------- 124.8/377.0 MB 4.7 MB/s eta 0:00:54
   ------------- -------------------------- 125.0/377.0 MB 4.7 MB/s eta 0:00:54
   ------------- -------------------------- 125.3/377.0 MB 4.7 MB/s eta 0:00:54
   ------------- -------------------------- 125.6/377.0 MB 4.7 MB/s eta 0:00:54
   ------------- -------------------------- 125.8/377.0 MB 4.7 MB/s eta 0:00:53
   ------------- -------------------------- 126.0/377.0 MB 4.7 MB/s eta 0:00:53
   ------------- -------------------------- 126.3/377.0 MB 4.8 MB/s eta 0:00:53
   ------------- -------------------------- 126.5/377.0 MB 4.8 MB/s eta 0:00:53
   ------------- -------------------------- 126.7/377.0 MB 4.8 MB/s eta 0:00:52
   ------------- -------------------------- 126.9/377.0 MB 4.8 MB/s eta 0:00:52
   ------------- -------------------------- 127.1/377.0 MB 4.8 MB/s eta 0:00:53
   ------------- -------------------------- 127.3/377.0 MB 4.8 MB/s eta 0:00:53
   ------------- -------------------------- 127.6/377.0 MB 4.8 MB/s eta 0:00:53
   ------------- -------------------------- 127.7/377.0 MB 4.8 MB/s eta 0:00:53
   ------------- -------------------------- 127.9/377.0 MB 4.7 MB/s eta 0:00:53
   ------------- -------------------------- 128.2/377.0 MB 4.7 MB/s eta 0:00:53
   ------------- -------------------------- 128.4/377.0 MB 4.7 MB/s eta 0:00:53
   ------------- -------------------------- 128.6/377.0 MB 4.7 MB/s eta 0:00:53
   ------------- -------------------------- 128.8/377.0 MB 4.7 MB/s eta 0:00:53
   ------------- -------------------------- 129.0/377.0 MB 4.7 MB/s eta 0:00:53
   ------------- -------------------------- 129.2/377.0 MB 4.7 MB/s eta 0:00:53
   ------------- -------------------------- 129.5/377.0 MB 4.7 MB/s eta 0:00:53
   ------------- -------------------------- 129.7/377.0 MB 4.7 MB/s eta 0:00:53
   ------------- -------------------------- 130.0/377.0 MB 4.8 MB/s eta 0:00:52
   ------------- -------------------------- 130.0/377.0 MB 4.7 MB/s eta 0:00:53
   ------------- -------------------------- 130.3/377.0 MB 4.7 MB/s eta 0:00:53
   ------------- -------------------------- 130.5/377.0 MB 4.7 MB/s eta 0:00:53
   ------------- -------------------------- 130.7/377.0 MB 4.7 MB/s eta 0:00:53
   ------------- -------------------------- 130.9/377.0 MB 4.7 MB/s eta 0:00:53
   ------------- -------------------------- 131.1/377.0 MB 4.6 MB/s eta 0:00:53
   ------------- -------------------------- 131.3/377.0 MB 4.6 MB/s eta 0:00:54
   ------------- -------------------------- 131.5/377.0 MB 4.6 MB/s eta 0:00:54
   ------------- -------------------------- 131.6/377.0 MB 4.6 MB/s eta 0:00:54
   ------------- -------------------------- 131.8/377.0 MB 4.6 MB/s eta 0:00:54
   -------------- ------------------------- 132.1/377.0 MB 4.6 MB/s eta 0:00:54
   -------------- ------------------------- 132.3/377.0 MB 4.6 MB/s eta 0:00:54
   -------------- ------------------------- 132.5/377.0 MB 4.6 MB/s eta 0:00:54
   -------------- ------------------------- 132.7/377.0 MB 4.6 MB/s eta 0:00:54
   -------------- ------------------------- 132.9/377.0 MB 4.5 MB/s eta 0:00:54
   -------------- ------------------------- 133.2/377.0 MB 4.5 MB/s eta 0:00:54
   -------------- ------------------------- 133.4/377.0 MB 4.6 MB/s eta 0:00:54
   -------------- ------------------------- 133.6/377.0 MB 4.6 MB/s eta 0:00:54
   -------------- ------------------------- 133.9/377.0 MB 4.5 MB/s eta 0:00:54
   -------------- ------------------------- 134.1/377.0 MB 4.6 MB/s eta 0:00:53
   -------------- ------------------------- 134.4/377.0 MB 4.5 MB/s eta 0:00:54
   -------------- ------------------------- 134.6/377.0 MB 4.6 MB/s eta 0:00:53
   -------------- ------------------------- 134.9/377.0 MB 4.6 MB/s eta 0:00:53
   -------------- ------------------------- 134.9/377.0 MB 4.5 MB/s eta 0:00:54
   -------------- ------------------------- 135.1/377.0 MB 4.6 MB/s eta 0:00:53
   -------------- ------------------------- 135.4/377.0 MB 4.5 MB/s eta 0:00:54
   -------------- ------------------------- 135.7/377.0 MB 4.6 MB/s eta 0:00:53
   -------------- ------------------------- 136.0/377.0 MB 4.6 MB/s eta 0:00:53
   -------------- ------------------------- 136.2/377.0 MB 4.6 MB/s eta 0:00:53
   -------------- ------------------------- 136.4/377.0 MB 4.6 MB/s eta 0:00:53
   -------------- ------------------------- 136.6/377.0 MB 4.5 MB/s eta 0:00:53
   -------------- ------------------------- 136.8/377.0 MB 4.5 MB/s eta 0:00:53
   -------------- ------------------------- 137.0/377.0 MB 4.5 MB/s eta 0:00:53
   -------------- ------------------------- 137.2/377.0 MB 4.5 MB/s eta 0:00:53
   -------------- ------------------------- 137.5/377.0 MB 4.6 MB/s eta 0:00:53
   -------------- ------------------------- 137.7/377.0 MB 4.5 MB/s eta 0:00:53
   -------------- ------------------------- 137.9/377.0 MB 4.5 MB/s eta 0:00:53
   -------------- ------------------------- 138.1/377.0 MB 4.5 MB/s eta 0:00:53
   -------------- ------------------------- 138.3/377.0 MB 4.5 MB/s eta 0:00:53
   -------------- ------------------------- 138.6/377.0 MB 4.5 MB/s eta 0:00:53
   -------------- ------------------------- 138.8/377.0 MB 4.5 MB/s eta 0:00:53
   -------------- ------------------------- 139.0/377.0 MB 4.5 MB/s eta 0:00:53
   -------------- ------------------------- 139.3/377.0 MB 4.6 MB/s eta 0:00:52
   -------------- ------------------------- 139.5/377.0 MB 4.6 MB/s eta 0:00:52
   -------------- ------------------------- 139.8/377.0 MB 4.6 MB/s eta 0:00:52
   -------------- ------------------------- 140.0/377.0 MB 4.6 MB/s eta 0:00:52
   -------------- ------------------------- 140.3/377.0 MB 4.7 MB/s eta 0:00:51
   -------------- ------------------------- 140.5/377.0 MB 4.7 MB/s eta 0:00:51
   -------------- ------------------------- 140.7/377.0 MB 4.7 MB/s eta 0:00:51
   -------------- ------------------------- 140.9/377.0 MB 4.6 MB/s eta 0:00:52
   -------------- ------------------------- 141.2/377.0 MB 4.7 MB/s eta 0:00:51
   --------------- ------------------------ 141.4/377.0 MB 4.7 MB/s eta 0:00:50
   --------------- ------------------------ 141.7/377.0 MB 4.8 MB/s eta 0:00:50
   --------------- ------------------------ 141.9/377.0 MB 4.8 MB/s eta 0:00:49
   --------------- ------------------------ 142.1/377.0 MB 4.8 MB/s eta 0:00:49
   --------------- ------------------------ 142.4/377.0 MB 4.8 MB/s eta 0:00:49
   --------------- ------------------------ 142.6/377.0 MB 4.8 MB/s eta 0:00:49
   --------------- ------------------------ 142.8/377.0 MB 4.8 MB/s eta 0:00:49
   --------------- ------------------------ 143.1/377.0 MB 4.9 MB/s eta 0:00:49
   --------------- ------------------------ 143.3/377.0 MB 4.9 MB/s eta 0:00:49
   --------------- ------------------------ 143.5/377.0 MB 4.8 MB/s eta 0:00:49
   --------------- ------------------------ 143.8/377.0 MB 4.8 MB/s eta 0:00:49
   --------------- ------------------------ 144.0/377.0 MB 4.8 MB/s eta 0:00:49
   --------------- ------------------------ 144.2/377.0 MB 4.8 MB/s eta 0:00:49
   --------------- ------------------------ 144.4/377.0 MB 4.9 MB/s eta 0:00:48
   --------------- ------------------------ 144.7/377.0 MB 4.8 MB/s eta 0:00:49
   --------------- ------------------------ 144.9/377.0 MB 4.8 MB/s eta 0:00:49
   --------------- ------------------------ 145.1/377.0 MB 4.8 MB/s eta 0:00:49
   --------------- ------------------------ 145.3/377.0 MB 4.8 MB/s eta 0:00:48
   --------------- ------------------------ 145.4/377.0 MB 4.9 MB/s eta 0:00:48
   --------------- ------------------------ 145.5/377.0 MB 4.7 MB/s eta 0:00:50
   --------------- ------------------------ 145.6/377.0 MB 4.7 MB/s eta 0:00:50
   --------------- ------------------------ 145.8/377.0 MB 4.6 MB/s eta 0:00:50
   --------------- ------------------------ 146.0/377.0 MB 4.6 MB/s eta 0:00:51
   --------------- ------------------------ 146.2/377.0 MB 4.6 MB/s eta 0:00:51
   --------------- ------------------------ 146.3/377.0 MB 4.5 MB/s eta 0:00:51
   --------------- ------------------------ 146.5/377.0 MB 4.5 MB/s eta 0:00:52
   --------------- ------------------------ 146.7/377.0 MB 4.5 MB/s eta 0:00:51
   --------------- ------------------------ 146.9/377.0 MB 4.5 MB/s eta 0:00:51
   --------------- ------------------------ 147.1/377.0 MB 4.5 MB/s eta 0:00:51
   --------------- ------------------------ 147.3/377.0 MB 4.5 MB/s eta 0:00:52
   --------------- ------------------------ 147.5/377.0 MB 4.5 MB/s eta 0:00:52
   --------------- ------------------------ 147.7/377.0 MB 4.5 MB/s eta 0:00:52
   --------------- ------------------------ 147.9/377.0 MB 4.5 MB/s eta 0:00:52
   --------------- ------------------------ 148.1/377.0 MB 4.5 MB/s eta 0:00:52
   --------------- ------------------------ 148.3/377.0 MB 4.5 MB/s eta 0:00:52
   --------------- ------------------------ 148.5/377.0 MB 4.4 MB/s eta 0:00:52
   --------------- ------------------------ 148.7/377.0 MB 4.5 MB/s eta 0:00:52
   --------------- ------------------------ 149.0/377.0 MB 4.4 MB/s eta 0:00:52
   --------------- ------------------------ 149.1/377.0 MB 4.4 MB/s eta 0:00:52
   --------------- ------------------------ 149.4/377.0 MB 4.5 MB/s eta 0:00:52
   --------------- ------------------------ 149.6/377.0 MB 4.4 MB/s eta 0:00:52
   --------------- ------------------------ 149.7/377.0 MB 4.4 MB/s eta 0:00:52
   --------------- ------------------------ 149.8/377.0 MB 4.3 MB/s eta 0:00:53
   --------------- ------------------------ 150.1/377.0 MB 4.3 MB/s eta 0:00:53
   --------------- ------------------------ 150.3/377.0 MB 4.4 MB/s eta 0:00:52
   --------------- ------------------------ 150.5/377.0 MB 4.3 MB/s eta 0:00:53
   ---------------- ----------------------- 150.8/377.0 MB 4.3 MB/s eta 0:00:53
   ---------------- ----------------------- 151.1/377.0 MB 4.4 MB/s eta 0:00:52
   ---------------- ----------------------- 151.3/377.0 MB 4.4 MB/s eta 0:00:52
   ---------------- ----------------------- 151.6/377.0 MB 4.3 MB/s eta 0:00:52
   ---------------- ----------------------- 151.8/377.0 MB 4.4 MB/s eta 0:00:52
   ---------------- ----------------------- 152.0/377.0 MB 4.3 MB/s eta 0:00:52
   ---------------- ----------------------- 152.1/377.0 MB 4.3 MB/s eta 0:00:53
   ---------------- ----------------------- 152.5/377.0 MB 4.3 MB/s eta 0:00:52
   ---------------- ----------------------- 152.7/377.0 MB 4.3 MB/s eta 0:00:52
   ---------------- ----------------------- 152.9/377.0 MB 4.3 MB/s eta 0:00:53
   ---------------- ----------------------- 153.1/377.0 MB 4.3 MB/s eta 0:00:52
   ---------------- ----------------------- 153.4/377.0 MB 4.3 MB/s eta 0:00:52
   ---------------- ----------------------- 153.6/377.0 MB 4.3 MB/s eta 0:00:52
   ---------------- ----------------------- 153.8/377.0 MB 4.3 MB/s eta 0:00:52
   ---------------- ----------------------- 154.0/377.0 MB 4.3 MB/s eta 0:00:52
   ---------------- ----------------------- 154.2/377.0 MB 4.3 MB/s eta 0:00:52
   ---------------- ----------------------- 154.5/377.0 MB 4.3 MB/s eta 0:00:52
   ---------------- ----------------------- 154.7/377.0 MB 4.3 MB/s eta 0:00:52
   ---------------- ----------------------- 154.8/377.0 MB 4.3 MB/s eta 0:00:52
   ---------------- ----------------------- 154.9/377.0 MB 4.2 MB/s eta 0:00:53
   ---------------- ----------------------- 155.1/377.0 MB 4.2 MB/s eta 0:00:53
   ---------------- ----------------------- 155.4/377.0 MB 4.3 MB/s eta 0:00:53
   ---------------- ----------------------- 155.6/377.0 MB 4.3 MB/s eta 0:00:53
   ---------------- ----------------------- 155.8/377.0 MB 4.4 MB/s eta 0:00:51
   ---------------- ----------------------- 156.1/377.0 MB 4.4 MB/s eta 0:00:51
   ---------------- ----------------------- 156.3/377.0 MB 4.5 MB/s eta 0:00:50
   ---------------- ----------------------- 156.5/377.0 MB 4.5 MB/s eta 0:00:50
   ---------------- ----------------------- 156.8/377.0 MB 4.5 MB/s eta 0:00:50
   ---------------- ----------------------- 157.0/377.0 MB 4.5 MB/s eta 0:00:49
   ---------------- ----------------------- 157.2/377.0 MB 4.5 MB/s eta 0:00:49
   ---------------- ----------------------- 157.4/377.0 MB 4.6 MB/s eta 0:00:48
   ---------------- ----------------------- 157.6/377.0 MB 4.5 MB/s eta 0:00:49
   ---------------- ----------------------- 157.9/377.0 MB 4.5 MB/s eta 0:00:49
   ---------------- ----------------------- 158.0/377.0 MB 4.5 MB/s eta 0:00:49
   ---------------- ----------------------- 158.3/377.0 MB 4.6 MB/s eta 0:00:48
   ---------------- ----------------------- 158.5/377.0 MB 4.6 MB/s eta 0:00:48
   ---------------- ----------------------- 158.7/377.0 MB 4.5 MB/s eta 0:00:49
   ---------------- ----------------------- 158.9/377.0 MB 4.6 MB/s eta 0:00:48
   ---------------- ----------------------- 159.1/377.0 MB 4.5 MB/s eta 0:00:49
   ---------------- ----------------------- 159.3/377.0 MB 4.5 MB/s eta 0:00:49
   ---------------- ----------------------- 159.5/377.0 MB 4.5 MB/s eta 0:00:49
   ---------------- ----------------------- 159.7/377.0 MB 4.5 MB/s eta 0:00:48
   ---------------- ----------------------- 159.9/377.0 MB 4.5 MB/s eta 0:00:48
   ---------------- ----------------------- 160.1/377.0 MB 4.6 MB/s eta 0:00:48
   ----------------- ---------------------- 160.3/377.0 MB 4.6 MB/s eta 0:00:47
   ----------------- ---------------------- 160.6/377.0 MB 4.6 MB/s eta 0:00:47
   ----------------- ---------------------- 160.8/377.0 MB 4.6 MB/s eta 0:00:47
   ----------------- ---------------------- 161.1/377.0 MB 4.6 MB/s eta 0:00:47
   ----------------- ---------------------- 161.3/377.0 MB 4.6 MB/s eta 0:00:47
   ----------------- ---------------------- 161.6/377.0 MB 4.6 MB/s eta 0:00:47
   ----------------- ---------------------- 161.8/377.0 MB 4.6 MB/s eta 0:00:47
   ----------------- ---------------------- 161.9/377.0 MB 4.6 MB/s eta 0:00:47
ERROR: Could not install packages due to an OSError: [Errno 28] No space left on device

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[113], line 3
      1 get_ipython().system('pip install tensorflow')
----> 3 import tensorflow as tf
      4 print(tf.__version__)

ModuleNotFoundError: No module named 'tensorflow'
In [ ]:
 
In [115]:
!pip --version
pip 23.2.1 from D:\New folder\Lib\site-packages\pip (python 3.11)

In [121]:
!D:\New folder\python.exe -m pip install --upgrade pip
'D:\New' is not recognized as an internal or external command,
operable program or batch file.
In [2]:
!pip install tensorflow
Requirement already satisfied: tensorflow in d:\new folder\lib\site-packages (2.16.1)
Requirement already satisfied: tensorflow-intel==2.16.1 in d:\new folder\lib\site-packages (from tensorflow) (2.16.1)
Requirement already satisfied: absl-py>=1.0.0 in d:\new folder\lib\site-packages (from tensorflow-intel==2.16.1->tensorflow) (2.1.0)
Requirement already satisfied: astunparse>=1.6.0 in d:\new folder\lib\site-packages (from tensorflow-intel==2.16.1->tensorflow) (1.6.3)
Requirement already satisfied: flatbuffers>=23.5.26 in d:\new folder\lib\site-packages (from tensorflow-intel==2.16.1->tensorflow) (24.3.25)
Requirement already satisfied: gast!=0.5.0,!=0.5.1,!=0.5.2,>=0.2.1 in d:\new folder\lib\site-packages (from tensorflow-intel==2.16.1->tensorflow) (0.5.4)
Requirement already satisfied: google-pasta>=0.1.1 in d:\new folder\lib\site-packages (from tensorflow-intel==2.16.1->tensorflow) (0.2.0)
Requirement already satisfied: h5py>=3.10.0 in d:\new folder\lib\site-packages (from tensorflow-intel==2.16.1->tensorflow) (3.11.0)
Requirement already satisfied: libclang>=13.0.0 in d:\new folder\lib\site-packages (from tensorflow-intel==2.16.1->tensorflow) (18.1.1)
Requirement already satisfied: ml-dtypes~=0.3.1 in d:\new folder\lib\site-packages (from tensorflow-intel==2.16.1->tensorflow) (0.3.2)
Requirement already satisfied: opt-einsum>=2.3.2 in d:\new folder\lib\site-packages (from tensorflow-intel==2.16.1->tensorflow) (3.3.0)
Requirement already satisfied: packaging in d:\new folder\lib\site-packages (from tensorflow-intel==2.16.1->tensorflow) (23.0)
Requirement already satisfied: protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0dev,>=3.20.3 in d:\new folder\lib\site-packages (from tensorflow-intel==2.16.1->tensorflow) (4.25.3)
Requirement already satisfied: requests<3,>=2.21.0 in d:\new folder\lib\site-packages (from tensorflow-intel==2.16.1->tensorflow) (2.31.0)
Requirement already satisfied: setuptools in d:\new folder\lib\site-packages (from tensorflow-intel==2.16.1->tensorflow) (68.0.0)
Requirement already satisfied: six>=1.12.0 in d:\new folder\lib\site-packages (from tensorflow-intel==2.16.1->tensorflow) (1.16.0)
Requirement already satisfied: termcolor>=1.1.0 in d:\new folder\lib\site-packages (from tensorflow-intel==2.16.1->tensorflow) (2.4.0)
Requirement already satisfied: typing-extensions>=3.6.6 in d:\new folder\lib\site-packages (from tensorflow-intel==2.16.1->tensorflow) (4.7.1)
Requirement already satisfied: wrapt>=1.11.0 in d:\new folder\lib\site-packages (from tensorflow-intel==2.16.1->tensorflow) (1.14.1)
Requirement already satisfied: grpcio<2.0,>=1.24.3 in d:\new folder\lib\site-packages (from tensorflow-intel==2.16.1->tensorflow) (1.62.2)
Requirement already satisfied: tensorboard<2.17,>=2.16 in d:\new folder\lib\site-packages (from tensorflow-intel==2.16.1->tensorflow) (2.16.2)
Requirement already satisfied: keras>=3.0.0 in d:\new folder\lib\site-packages (from tensorflow-intel==2.16.1->tensorflow) (3.3.3)
Requirement already satisfied: tensorflow-io-gcs-filesystem>=0.23.1 in d:\new folder\lib\site-packages (from tensorflow-intel==2.16.1->tensorflow) (0.31.0)
Requirement already satisfied: numpy<2.0.0,>=1.23.5 in d:\new folder\lib\site-packages (from tensorflow-intel==2.16.1->tensorflow) (1.24.3)
Requirement already satisfied: wheel<1.0,>=0.23.0 in d:\new folder\lib\site-packages (from astunparse>=1.6.0->tensorflow-intel==2.16.1->tensorflow) (0.38.4)
Requirement already satisfied: rich in d:\new folder\lib\site-packages (from keras>=3.0.0->tensorflow-intel==2.16.1->tensorflow) (13.7.1)
Requirement already satisfied: namex in d:\new folder\lib\site-packages (from keras>=3.0.0->tensorflow-intel==2.16.1->tensorflow) (0.0.8)
Requirement already satisfied: optree in d:\new folder\lib\site-packages (from keras>=3.0.0->tensorflow-intel==2.16.1->tensorflow) (0.11.0)
Requirement already satisfied: charset-normalizer<4,>=2 in d:\new folder\lib\site-packages (from requests<3,>=2.21.0->tensorflow-intel==2.16.1->tensorflow) (2.0.4)
Requirement already satisfied: idna<4,>=2.5 in d:\new folder\lib\site-packages (from requests<3,>=2.21.0->tensorflow-intel==2.16.1->tensorflow) (3.4)
Requirement already satisfied: urllib3<3,>=1.21.1 in d:\new folder\lib\site-packages (from requests<3,>=2.21.0->tensorflow-intel==2.16.1->tensorflow) (1.26.16)
Requirement already satisfied: certifi>=2017.4.17 in d:\new folder\lib\site-packages (from requests<3,>=2.21.0->tensorflow-intel==2.16.1->tensorflow) (2023.7.22)
Requirement already satisfied: markdown>=2.6.8 in d:\new folder\lib\site-packages (from tensorboard<2.17,>=2.16->tensorflow-intel==2.16.1->tensorflow) (3.4.1)
Requirement already satisfied: tensorboard-data-server<0.8.0,>=0.7.0 in d:\new folder\lib\site-packages (from tensorboard<2.17,>=2.16->tensorflow-intel==2.16.1->tensorflow) (0.7.2)
Requirement already satisfied: werkzeug>=1.0.1 in d:\new folder\lib\site-packages (from tensorboard<2.17,>=2.16->tensorflow-intel==2.16.1->tensorflow) (2.2.3)
Requirement already satisfied: MarkupSafe>=2.1.1 in d:\new folder\lib\site-packages (from werkzeug>=1.0.1->tensorboard<2.17,>=2.16->tensorflow-intel==2.16.1->tensorflow) (2.1.1)
Requirement already satisfied: markdown-it-py>=2.2.0 in d:\new folder\lib\site-packages (from rich->keras>=3.0.0->tensorflow-intel==2.16.1->tensorflow) (2.2.0)
Requirement already satisfied: pygments<3.0.0,>=2.13.0 in d:\new folder\lib\site-packages (from rich->keras>=3.0.0->tensorflow-intel==2.16.1->tensorflow) (2.15.1)
Requirement already satisfied: mdurl~=0.1 in d:\new folder\lib\site-packages (from markdown-it-py>=2.2.0->rich->keras>=3.0.0->tensorflow-intel==2.16.1->tensorflow) (0.1.0)
In [3]:
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_squared_error
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense

# Assume X_train, X_test, y_train, y_test are already prepared

# Scaling features
scaler = StandardScaler()
X_train_scaled = scaler.fit_transform(X_train)
X_test_scaled = scaler.transform(X_test)

# Training Random Forest model
rf_model = RandomForestRegressor(n_estimators=100, random_state=42)
rf_model.fit(X_train_scaled, y_train)

# Training Artificial Neural Network model
ann_model = Sequential()
ann_model.add(Dense(64, activation='relu', input_shape=(X_train_scaled.shape[1],)))
ann_model.add(Dense(32, activation='relu'))
ann_model.add(Dense(1))  # Output layer
ann_model.compile(optimizer='adam', loss='mse')
ann_model.fit(X_train_scaled, y_train, epochs=50, batch_size=32, verbose=0)

# Evaluation
rf_pred = rf_model.predict(X_test_scaled)
ann_pred = ann_model.predict(X_test_scaled).flatten()

rf_rmse = mean_squared_error(y_test, rf_pred, squared=False)
ann_rmse = mean_squared_error(y_test, ann_pred, squared=False)

print("Random Forest RMSE:", rf_rmse)
print("Artificial Neural Network RMSE:", ann_rmse)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[3], line 12
      8 # Assume X_train, X_test, y_train, y_test are already prepared
      9 
     10 # Scaling features
     11 scaler = StandardScaler()
---> 12 X_train_scaled = scaler.fit_transform(X_train)
     13 X_test_scaled = scaler.transform(X_test)
     15 # Training Random Forest model

NameError: name 'X_train' is not defined
In [5]:
# check the test and train data 

# Print the shapes of your data arrays
print("X_train shape:", X_train.shape)
print("X_test shape:", X_test.shape)
print("y_train shape:", y_train.shape)
print("y_test shape:", y_test.shape)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[5], line 4
      1 # check the test and train data 
      2 
      3 # Print the shapes of your data arrays
----> 4 print("X_train shape:", X_train.shape)
      5 print("X_test shape:", X_test.shape)
      6 print("y_train shape:", y_train.shape)

NameError: name 'X_train' is not defined
In [6]:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_squared_error
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
from sklearn.preprocessing import StandardScaler

# Step 1: Load the data
data = pd.read_csv("Axis_Bank_Ltd__stock_data.csv")

# Step 2: Prepare the data
X = data.drop(columns=["Close"])  # Features (independent variables)
y = data["Close"]  # Target variable (dependent variable)

# Split the data into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Step 3: Train the models

# Train Random Forest (RF) model
rf_model = RandomForestRegressor(n_estimators=100, random_state=42)
rf_model.fit(X_train, y_train)

# Train Artificial Neural Network (ANN) model
scaler = StandardScaler()
X_train_scaled = scaler.fit_transform(X_train)
X_test_scaled = scaler.transform(X_test)

ann_model = Sequential()
ann_model.add(Dense(64, activation='relu', input_shape=(X_train_scaled.shape[1],)))
ann_model.add(Dense(32, activation='relu'))
ann_model.add(Dense(1))  # Output layer
ann_model.compile(optimizer='adam', loss='mse')
ann_model.fit(X_train_scaled, y_train, epochs=50, batch_size=32, verbose=0)

# Step 4: Evaluate the models
rf_pred = rf_model.predict(X_test)
ann_pred = ann_model.predict(X_test_scaled).flatten()

rf_rmse = mean_squared_error(y_test, rf_pred, squared=False)
ann_rmse = mean_squared_error(y_test, ann_pred, squared=False)

print("Random Forest RMSE:", rf_rmse)
print("Artificial Neural Network RMSE:", ann_rmse)

# Step 5: Make predictions (if needed)
# You can use the trained models to make predictions on new data if required.
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[6], line 23
     19 # Step 3: Train the models
     20 
     21 # Train Random Forest (RF) model
     22 rf_model = RandomForestRegressor(n_estimators=100, random_state=42)
---> 23 rf_model.fit(X_train, y_train)
     25 # Train Artificial Neural Network (ANN) model
     26 scaler = StandardScaler()

File D:\New folder\Lib\site-packages\sklearn\base.py:1151, in _fit_context.<locals>.decorator.<locals>.wrapper(estimator, *args, **kwargs)
   1144     estimator._validate_params()
   1146 with config_context(
   1147     skip_parameter_validation=(
   1148         prefer_skip_nested_validation or global_skip_validation
   1149     )
   1150 ):
-> 1151     return fit_method(estimator, *args, **kwargs)

File D:\New folder\Lib\site-packages\sklearn\ensemble\_forest.py:348, in BaseForest.fit(self, X, y, sample_weight)
    346 if issparse(y):
    347     raise ValueError("sparse multilabel-indicator for y is not supported.")
--> 348 X, y = self._validate_data(
    349     X, y, multi_output=True, accept_sparse="csc", dtype=DTYPE
    350 )
    351 if sample_weight is not None:
    352     sample_weight = _check_sample_weight(sample_weight, X)

File D:\New folder\Lib\site-packages\sklearn\base.py:621, in BaseEstimator._validate_data(self, X, y, reset, validate_separately, cast_to_ndarray, **check_params)
    619         y = check_array(y, input_name="y", **check_y_params)
    620     else:
--> 621         X, y = check_X_y(X, y, **check_params)
    622     out = X, y
    624 if not no_val_X and check_params.get("ensure_2d", True):

File D:\New folder\Lib\site-packages\sklearn\utils\validation.py:1147, in check_X_y(X, y, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, multi_output, ensure_min_samples, ensure_min_features, y_numeric, estimator)
   1142         estimator_name = _check_estimator_name(estimator)
   1143     raise ValueError(
   1144         f"{estimator_name} requires y to be passed, but the target y is None"
   1145     )
-> 1147 X = check_array(
   1148     X,
   1149     accept_sparse=accept_sparse,
   1150     accept_large_sparse=accept_large_sparse,
   1151     dtype=dtype,
   1152     order=order,
   1153     copy=copy,
   1154     force_all_finite=force_all_finite,
   1155     ensure_2d=ensure_2d,
   1156     allow_nd=allow_nd,
   1157     ensure_min_samples=ensure_min_samples,
   1158     ensure_min_features=ensure_min_features,
   1159     estimator=estimator,
   1160     input_name="X",
   1161 )
   1163 y = _check_y(y, multi_output=multi_output, y_numeric=y_numeric, estimator=estimator)
   1165 check_consistent_length(X, y)

File D:\New folder\Lib\site-packages\sklearn\utils\validation.py:917, in check_array(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, estimator, input_name)
    915         array = xp.astype(array, dtype, copy=False)
    916     else:
--> 917         array = _asarray_with_order(array, order=order, dtype=dtype, xp=xp)
    918 except ComplexWarning as complex_warning:
    919     raise ValueError(
    920         "Complex data not supported\n{}\n".format(array)
    921     ) from complex_warning

File D:\New folder\Lib\site-packages\sklearn\utils\_array_api.py:380, in _asarray_with_order(array, dtype, order, copy, xp)
    378     array = numpy.array(array, order=order, dtype=dtype)
    379 else:
--> 380     array = numpy.asarray(array, order=order, dtype=dtype)
    382 # At this point array is a NumPy ndarray. We convert it to an array
    383 # container that is consistent with the input's namespace.
    384 return xp.asarray(array)

File D:\New folder\Lib\site-packages\pandas\core\generic.py:2070, in NDFrame.__array__(self, dtype)
   2069 def __array__(self, dtype: npt.DTypeLike | None = None) -> np.ndarray:
-> 2070     return np.asarray(self._values, dtype=dtype)

ValueError: could not convert string to float: '2021-04-22'
In [ ]:
 
In [11]:
numeric_columns = X_train.select_dtypes(include=['number']).columns
In [12]:
import pandas as pd

# Load the dataset into a DataFrame
df = pd.read_csv('Axis_Bank_Ltd__stock_data.csv')

# Display the data types of each column
print(df.dtypes)
Date          object
Open         float64
High         float64
Low          float64
Close        float64
Adj Close    float64
Volume         int64
dtype: object
In [13]:
# Display unique values in the "Date" column
print(df['Date'].unique())
['2012-04-23' '2012-04-24' '2012-04-25' ... '2022-04-18' '2022-04-19'
 '2022-04-20']

For my analysis I have to convert the date column in to month, day, week format so 1 done that then the ANN nad RFanalysis

In [14]:
# This code will preprocess the "Date" column by converting it to datetime format and then extracting relevant date features such as year, month, day, and day of the week
import pandas as pd

# Load your dataset into a pandas DataFrame
df = pd.read_csv('Axis_Bank_Ltd__stock_data.csv')

# Convert 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Extract relevant date features
df['Year'] = df['Date'].dt.year
df['Month'] = df['Date'].dt.month
df['Day'] = df['Date'].dt.day
df['DayOfWeek'] = df['Date'].dt.dayofweek  # Monday=0, Sunday=6

# Drop the original 'Date' column if not needed
df.drop(columns=['Date'], inplace=True)

# Display the first few rows of the DataFrame to verify the changes
print(df.head())
         Open        High         Low       Close   Adj Close    Volume  Year  \
0  235.600006  237.679993  225.399994  226.889999  211.339142   7525865  2012   
1  228.380005  228.410004  217.800003  222.779999  207.510834  12742675  2012   
2  222.800003  225.000000  216.250000  218.949997  203.943314  14089155  2012   
3  219.199997  219.789993  215.229996  217.330002  202.434402  10928690  2012   
4  217.940002  223.190002  217.800003  220.800003  205.666550  12637520  2012   

   Month  Day  DayOfWeek  
0      4   23          0  
1      4   24          1  
2      4   25          2  
3      4   26          3  
4      4   27          4  
In [15]:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_squared_error
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense

# Load your dataset into a pandas DataFrame
df = pd.read_csv('Axis_Bank_Ltd__stock_data.csv')

# Convert the 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Extract features from the date column
df['Year'] = df['Date'].dt.year
df['Month'] = df['Date'].dt.month
df['Day'] = df['Date'].dt.day
# You can add more features like day of the week, quarter, etc., if needed

# Define your features (X) and target variable (y)
X = df.drop(columns=['Date', 'Close'])  # Features excluding the 'Date' and 'Close' columns
y = df['Close']  # Target variable

# Split the data into training and testing sets (80% train, 20% test)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Scaling features (for ANN)
scaler = StandardScaler()
X_train_scaled = scaler.fit_transform(X_train)
X_test_scaled = scaler.transform(X_test)

# Train Random Forest (RF) model
rf_model = RandomForestRegressor(n_estimators=100, random_state=42)
rf_model.fit(X_train, y_train)

# Train Artificial Neural Network (ANN) model
ann_model = Sequential()
ann_model.add(Dense(64, activation='relu', input_shape=(X_train.shape[1],)))
ann_model.add(Dense(32, activation='relu'))
ann_model.add(Dense(1))  # Output layer
ann_model.compile(optimizer='adam', loss='mse')
ann_model.fit(X_train_scaled, y_train, epochs=50, batch_size=32, verbose=0)

# Evaluation
rf_pred = rf_model.predict(X_test)
ann_pred = ann_model.predict(X_test_scaled).flatten()

rf_rmse = mean_squared_error(y_test, rf_pred, squared=False)
ann_rmse = mean_squared_error(y_test, ann_pred, squared=False)

print("Random Forest RMSE:", rf_rmse)
print("Artificial Neural Network RMSE:", ann_rmse)
D:\New folder\Lib\site-packages\keras\src\layers\core\dense.py:87: UserWarning: Do not pass an `input_shape`/`input_dim` argument to a layer. When using Sequential models, prefer using an `Input(shape)` object as the first layer in the model instead.
  super().__init__(activity_regularizer=activity_regularizer, **kwargs)
16/16 ━━━━━━━━━━━━━━━━━━━━ 0s 6ms/step
Random Forest RMSE: 2.130441473389519
Artificial Neural Network RMSE: 11.483061710753844
In [17]:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_squared_error
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Input

# Load your dataset into a pandas DataFrame
df = pd.read_csv('HDFC_Bank_Ltd__stock_data.csv')

# Convert the 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Extract features from the date column
df['Year'] = df['Date'].dt.year
df['Month'] = df['Date'].dt.month
df['Day'] = df['Date'].dt.day
# You can add more features like day of the week, quarter, etc., if needed

# Define your features (X) and target variable (y)
X = df.drop(columns=['Date', 'Close'])  # Features excluding the 'Date' and 'Close' columns
y = df['Close']  # Target variable

# Split the data into training and testing sets (80% train, 20% test)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Scaling features (for ANN)
scaler = StandardScaler()
X_train_scaled = scaler.fit_transform(X_train)
X_test_scaled = scaler.transform(X_test)

# Train Random Forest (RF) model
rf_model = RandomForestRegressor(n_estimators=100, random_state=42)
rf_model.fit(X_train, y_train)

# Train Artificial Neural Network (ANN) model
ann_model = Sequential()
ann_model.add(Input(shape=(X_train.shape[1],)))  # Input layer
ann_model.add(Dense(64, activation='relu'))
ann_model.add(Dense(32, activation='relu'))
ann_model.add(Dense(1))  # Output layer
ann_model.compile(optimizer='adam', loss='mse')
ann_model.fit(X_train_scaled, y_train, epochs=50, batch_size=32, verbose=0)

# Evaluation
rf_pred = rf_model.predict(X_test)
ann_pred = ann_model.predict(X_test_scaled).flatten()

rf_rmse = mean_squared_error(y_test, rf_pred, squared=False)
ann_rmse = mean_squared_error(y_test, ann_pred, squared=False)

print("Random Forest RMSE:", rf_rmse)
print("Artificial Neural Network RMSE:", ann_rmse)
16/16 ━━━━━━━━━━━━━━━━━━━━ 0s 8ms/step
Random Forest RMSE: 2.9691473776738175
Artificial Neural Network RMSE: 36.19560012631673
In [18]:
# This code will preprocess the "Date" column by converting it to datetime format and then extracting relevant date features such as year, month, day, and day of the week
import pandas as pd

# Load your dataset into a pandas DataFrame
df = pd.read_csv('Bharti_Airtel_Ltd__stock_data.csv')

# Convert 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Extract relevant date features
df['Year'] = df['Date'].dt.year
df['Month'] = df['Date'].dt.month
df['Day'] = df['Date'].dt.day
df['DayOfWeek'] = df['Date'].dt.dayofweek  # Monday=0, Sunday=6

# Drop the original 'Date' column if not needed
df.drop(columns=['Date'], inplace=True)

# Display the first few rows of the DataFrame to verify the changes
print(df.head())
         Open        High         Low       Close   Adj Close    Volume  Year  \
0  290.745605  294.260498  279.750244  281.642883  264.660217   3988935  2012   
1  275.874847  279.119385  260.418274  277.001434  260.298645  15317269  2012   
2  274.883453  284.481842  274.883453  282.093536  265.083710   4544523  2012   
3  283.896027  285.653503  275.334106  277.857605  261.103180   6731235  2012   
4  277.857605  282.093536  273.080963  277.046478  260.340973   5027621  2012   

   Month  Day  DayOfWeek  
0      4   23          0  
1      4   24          1  
2      4   25          2  
3      4   26          3  
4      4   27          4  
In [19]:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_squared_error
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Input

# Load your dataset into a pandas DataFrame
df = pd.read_csv('Bharti_Airtel_Ltd__stock_data.csv')

# Convert the 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Extract features from the date column
df['Year'] = df['Date'].dt.year
df['Month'] = df['Date'].dt.month
df['Day'] = df['Date'].dt.day
# You can add more features like day of the week, quarter, etc., if needed

# Define your features (X) and target variable (y)
X = df.drop(columns=['Date', 'Close'])  # Features excluding the 'Date' and 'Close' columns
y = df['Close']  # Target variable

# Split the data into training and testing sets (80% train, 20% test)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Scaling features (for ANN)
scaler = StandardScaler()
X_train_scaled = scaler.fit_transform(X_train)
X_test_scaled = scaler.transform(X_test)

# Train Random Forest (RF) model
rf_model = RandomForestRegressor(n_estimators=100, random_state=42)
rf_model.fit(X_train, y_train)

# Train Artificial Neural Network (ANN) model
ann_model = Sequential()
ann_model.add(Input(shape=(X_train.shape[1],)))  # Input layer
ann_model.add(Dense(64, activation='relu'))
ann_model.add(Dense(32, activation='relu'))
ann_model.add(Dense(1))  # Output layer
ann_model.compile(optimizer='adam', loss='mse')
ann_model.fit(X_train_scaled, y_train, epochs=50, batch_size=32, verbose=0)

# Evaluation
rf_pred = rf_model.predict(X_test)
ann_pred = ann_model.predict(X_test_scaled).flatten()

rf_rmse = mean_squared_error(y_test, rf_pred, squared=False)
ann_rmse = mean_squared_error(y_test, ann_pred, squared=False)

print("Random Forest RMSE:", rf_rmse)
print("Artificial Neural Network RMSE:", ann_rmse)
16/16 ━━━━━━━━━━━━━━━━━━━━ 0s 6ms/step
Random Forest RMSE: 1.9819016994598802
Artificial Neural Network RMSE: 6.024143924763618
In [20]:
# This code will preprocess the "Date" column by converting it to datetime format and then extracting relevant date features such as year, month, day, and day of the week
import pandas as pd

# Load your dataset into a pandas DataFrame
df = pd.read_csv('HDFC_Bank_Ltd__stock_data.csv')

# Convert 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Extract relevant date features
df['Year'] = df['Date'].dt.year
df['Month'] = df['Date'].dt.month
df['Day'] = df['Date'].dt.day
df['DayOfWeek'] = df['Date'].dt.dayofweek  # Monday=0, Sunday=6

# Drop the original 'Date' column if not needed
df.drop(columns=['Date'], inplace=True)

# Display the first few rows of the DataFrame to verify the changes
print(df.head())
         Open        High         Low       Close   Adj Close   Volume  Year  \
0  275.975006  278.000000  271.649994  272.674988  249.466324  4218824  2012   
1  273.049988  273.250000  269.700012  270.924988  247.865295  4380390  2012   
2  272.000000  274.750000  269.000000  273.325012  250.061035  5389194  2012   
3  272.500000  274.975006  269.500000  270.250000  247.247757  4669476  2012   
4  271.000000  273.000000  267.100006  270.575012  247.545059  2274510  2012   

   Month  Day  DayOfWeek  
0      4   23          0  
1      4   24          1  
2      4   25          2  
3      4   26          3  
4      4   27          4  
In [21]:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_squared_error
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Input

# Load your dataset into a pandas DataFrame
df = pd.read_csv('HDFC_Bank_Ltd__stock_data.csv')

# Convert the 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Extract features from the date column
df['Year'] = df['Date'].dt.year
df['Month'] = df['Date'].dt.month
df['Day'] = df['Date'].dt.day
# You can add more features like day of the week, quarter, etc., if needed

# Define your features (X) and target variable (y)
X = df.drop(columns=['Date', 'Close'])  # Features excluding the 'Date' and 'Close' columns
y = df['Close']  # Target variable

# Split the data into training and testing sets (80% train, 20% test)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Scaling features (for ANN)
scaler = StandardScaler()
X_train_scaled = scaler.fit_transform(X_train)
X_test_scaled = scaler.transform(X_test)

# Train Random Forest (RF) model
rf_model = RandomForestRegressor(n_estimators=100, random_state=42)
rf_model.fit(X_train, y_train)

# Train Artificial Neural Network (ANN) model
ann_model = Sequential()
ann_model.add(Input(shape=(X_train.shape[1],)))  # Input layer
ann_model.add(Dense(64, activation='relu'))
ann_model.add(Dense(32, activation='relu'))
ann_model.add(Dense(1))  # Output layer
ann_model.compile(optimizer='adam', loss='mse')
ann_model.fit(X_train_scaled, y_train, epochs=50, batch_size=32, verbose=0)

# Evaluation
rf_pred = rf_model.predict(X_test)
ann_pred = ann_model.predict(X_test_scaled).flatten()

rf_rmse = mean_squared_error(y_test, rf_pred, squared=False)
ann_rmse = mean_squared_error(y_test, ann_pred, squared=False)

print("Random Forest RMSE:", rf_rmse)
print("Artificial Neural Network RMSE:", ann_rmse)
16/16 ━━━━━━━━━━━━━━━━━━━━ 0s 7ms/step
Random Forest RMSE: 2.9691473776738175
Artificial Neural Network RMSE: 33.80899700463722
In [22]:
# This code will preprocess the "Date" column by converting it to datetime format and then extracting relevant date features such as year, month, day, and day of the week
import pandas as pd

# Load your dataset into a pandas DataFrame
df = pd.read_csv('Hindustan_Unilever_Ltd__stock_data.csv')

# Convert 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Extract relevant date features
df['Year'] = df['Date'].dt.year
df['Month'] = df['Date'].dt.month
df['Day'] = df['Date'].dt.day
df['DayOfWeek'] = df['Date'].dt.dayofweek  # Monday=0, Sunday=6

# Drop the original 'Date' column if not needed
df.drop(columns=['Date'], inplace=True)

# Display the first few rows of the DataFrame to verify the changes
print(df.head())
         Open        High         Low       Close   Adj Close   Volume  Year  \
0  422.350006  424.350006  416.000000  417.100006  340.191559   498101  2012   
1  417.899994  423.350006  416.350006  420.500000  342.964630  1386044  2012   
2  419.350006  422.000000  416.399994  419.100006  341.822876  1021535  2012   
3  418.100006  419.850006  412.250000  414.700012  338.234100  2175667  2012   
4  414.000000  418.299988  412.549988  415.399994  338.805054  2408519  2012   

   Month  Day  DayOfWeek  
0      4   23          0  
1      4   24          1  
2      4   25          2  
3      4   26          3  
4      4   27          4  
In [23]:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_squared_error
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Input

# Load your dataset into a pandas DataFrame
df = pd.read_csv('Hindustan_Unilever_Ltd__stock_data.csv')

# Convert the 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Extract features from the date column
df['Year'] = df['Date'].dt.year
df['Month'] = df['Date'].dt.month
df['Day'] = df['Date'].dt.day
# You can add more features like day of the week, quarter, etc., if needed

# Define your features (X) and target variable (y)
X = df.drop(columns=['Date', 'Close'])  # Features excluding the 'Date' and 'Close' columns
y = df['Close']  # Target variable

# Split the data into training and testing sets (80% train, 20% test)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Scaling features (for ANN)
scaler = StandardScaler()
X_train_scaled = scaler.fit_transform(X_train)
X_test_scaled = scaler.transform(X_test)

# Train Random Forest (RF) model
rf_model = RandomForestRegressor(n_estimators=100, random_state=42)
rf_model.fit(X_train, y_train)

# Train Artificial Neural Network (ANN) model
ann_model = Sequential()
ann_model.add(Input(shape=(X_train.shape[1],)))  # Input layer
ann_model.add(Dense(64, activation='relu'))
ann_model.add(Dense(32, activation='relu'))
ann_model.add(Dense(1))  # Output layer
ann_model.compile(optimizer='adam', loss='mse')
ann_model.fit(X_train_scaled, y_train, epochs=50, batch_size=32, verbose=0)

# Evaluation
rf_pred = rf_model.predict(X_test)
ann_pred = ann_model.predict(X_test_scaled).flatten()

rf_rmse = mean_squared_error(y_test, rf_pred, squared=False)
ann_rmse = mean_squared_error(y_test, ann_pred, squared=False)

print("Random Forest RMSE:", rf_rmse)
print("Artificial Neural Network RMSE:", ann_rmse)
16/16 ━━━━━━━━━━━━━━━━━━━━ 0s 7ms/step
Random Forest RMSE: 8.902062917783587
Artificial Neural Network RMSE: 67.24023486113327
In [24]:
# This code will preprocess the "Date" column by converting it to datetime format and then extracting relevant date features such as year, month, day, and day of the week
import pandas as pd

# Load your dataset into a pandas DataFrame
df = pd.read_csv('ICICI_Bank_Ltd__stock_data.csv')

# Convert 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Extract relevant date features
df['Year'] = df['Date'].dt.year
df['Month'] = df['Date'].dt.month
df['Day'] = df['Date'].dt.day
df['DayOfWeek'] = df['Date'].dt.dayofweek  # Monday=0, Sunday=6

# Drop the original 'Date' column if not needed
df.drop(columns=['Date'], inplace=True)

# Display the first few rows of the DataFrame to verify the changes
print(df.head())
         Open        High         Low       Close   Adj Close    Volume  Year  \
0  154.545456  157.909088  152.018188  153.436356  133.668579  17939993  2012   
1  154.545456  155.172729  152.418182  154.145447  134.286301  17862146  2012   
2  153.645447  155.545456  150.409088  152.436356  132.797394  29238880  2012   
3  152.754547  153.754547  151.909088  152.990906  133.280502  24080837  2012   
4  153.727264  159.090912  152.918182  156.518188  136.353363  80624329  2012   

   Month  Day  DayOfWeek  
0      4   23          0  
1      4   24          1  
2      4   25          2  
3      4   26          3  
4      4   27          4  
In [25]:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_squared_error
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Input

# Load your dataset into a pandas DataFrame
df = pd.read_csv('ICICI_Bank_Ltd__stock_data.csv')

# Convert the 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Extract features from the date column
df['Year'] = df['Date'].dt.year
df['Month'] = df['Date'].dt.month
df['Day'] = df['Date'].dt.day
# You can add more features like day of the week, quarter, etc., if needed

# Define your features (X) and target variable (y)
X = df.drop(columns=['Date', 'Close'])  # Features excluding the 'Date' and 'Close' columns
y = df['Close']  # Target variable

# Split the data into training and testing sets (80% train, 20% test)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Scaling features (for ANN)
scaler = StandardScaler()
X_train_scaled = scaler.fit_transform(X_train)
X_test_scaled = scaler.transform(X_test)

# Train Random Forest (RF) model
rf_model = RandomForestRegressor(n_estimators=100, random_state=42)
rf_model.fit(X_train, y_train)

# Train Artificial Neural Network (ANN) model
ann_model = Sequential()
ann_model.add(Input(shape=(X_train.shape[1],)))  # Input layer
ann_model.add(Dense(64, activation='relu'))
ann_model.add(Dense(32, activation='relu'))
ann_model.add(Dense(1))  # Output layer
ann_model.compile(optimizer='adam', loss='mse')
ann_model.fit(X_train_scaled, y_train, epochs=50, batch_size=32, verbose=0)

# Evaluation
rf_pred = rf_model.predict(X_test)
ann_pred = ann_model.predict(X_test_scaled).flatten()

rf_rmse = mean_squared_error(y_test, rf_pred, squared=False)
ann_rmse = mean_squared_error(y_test, ann_pred, squared=False)

print("Random Forest RMSE:", rf_rmse)
print("Artificial Neural Network RMSE:", ann_rmse)
16/16 ━━━━━━━━━━━━━━━━━━━━ 0s 6ms/step
Random Forest RMSE: 1.61398472397264
Artificial Neural Network RMSE: 7.292356645324942
In [26]:
# This code will preprocess the "Date" column by converting it to datetime format and then extracting relevant date features such as year, month, day, and day of the week
import pandas as pd

# Load your dataset into a pandas DataFrame
df = pd.read_csv('Infosys_Ltd__stock_data.csv')

# Convert 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Extract relevant date features
df['Year'] = df['Date'].dt.year
df['Month'] = df['Date'].dt.month
df['Day'] = df['Date'].dt.day
df['DayOfWeek'] = df['Date'].dt.dayofweek  # Monday=0, Sunday=6

# Drop the original 'Date' column if not needed
df.drop(columns=['Date'], inplace=True)

# Display the first few rows of the DataFrame to verify the changes
print(df.head())
         Open        High         Low       Close   Adj Close    Volume  Year  \
0  298.750000  298.750000  288.125000  288.862488  221.152878  18136696  2012   
1  288.831238  295.600006  274.787506  293.693756  224.851654  53037912  2012   
2  293.712494  295.625000  287.906250  293.743744  224.889938  24638504  2012   
3  293.750000  297.350006  292.793762  294.524994  225.488083  17137064  2012   
4  294.625000  299.750000  294.375000  298.875000  228.818405  14062464  2012   

   Month  Day  DayOfWeek  
0      4   23          0  
1      4   24          1  
2      4   25          2  
3      4   26          3  
4      4   27          4  
In [27]:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_squared_error
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Input

# Load your dataset into a pandas DataFrame
df = pd.read_csv('Infosys_Ltd__stock_data.csv')

# Convert the 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Extract features from the date column
df['Year'] = df['Date'].dt.year
df['Month'] = df['Date'].dt.month
df['Day'] = df['Date'].dt.day
# You can add more features like day of the week, quarter, etc., if needed

# Define your features (X) and target variable (y)
X = df.drop(columns=['Date', 'Close'])  # Features excluding the 'Date' and 'Close' columns
y = df['Close']  # Target variable

# Split the data into training and testing sets (80% train, 20% test)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Scaling features (for ANN)
scaler = StandardScaler()
X_train_scaled = scaler.fit_transform(X_train)
X_test_scaled = scaler.transform(X_test)

# Train Random Forest (RF) model
rf_model = RandomForestRegressor(n_estimators=100, random_state=42)
rf_model.fit(X_train, y_train)

# Train Artificial Neural Network (ANN) model
ann_model = Sequential()
ann_model.add(Input(shape=(X_train.shape[1],)))  # Input layer
ann_model.add(Dense(64, activation='relu'))
ann_model.add(Dense(32, activation='relu'))
ann_model.add(Dense(1))  # Output layer
ann_model.compile(optimizer='adam', loss='mse')
ann_model.fit(X_train_scaled, y_train, epochs=50, batch_size=32, verbose=0)

# Evaluation
rf_pred = rf_model.predict(X_test)
ann_pred = ann_model.predict(X_test_scaled).flatten()

rf_rmse = mean_squared_error(y_test, rf_pred, squared=False)
ann_rmse = mean_squared_error(y_test, ann_pred, squared=False)

print("Random Forest RMSE:", rf_rmse)
print("Artificial Neural Network RMSE:", ann_rmse)
16/16 ━━━━━━━━━━━━━━━━━━━━ 0s 7ms/step
Random Forest RMSE: 4.254787056406641
Artificial Neural Network RMSE: 31.776797815813428
In [28]:
# This code will preprocess the "Date" column by converting it to datetime format and then extracting relevant date features such as year, month, day, and day of the week
import pandas as pd

# Load your dataset into a pandas DataFrame
df = pd.read_csv('Kotak_Mahindra_Bank_Ltd__stock_data.csv')

# Convert 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Extract relevant date features
df['Year'] = df['Date'].dt.year
df['Month'] = df['Date'].dt.month
df['Day'] = df['Date'].dt.day
df['DayOfWeek'] = df['Date'].dt.dayofweek  # Monday=0, Sunday=6

# Drop the original 'Date' column if not needed
df.drop(columns=['Date'], inplace=True)

# Display the first few rows of the DataFrame to verify the changes
print(df.head())
         Open        High         Low       Close   Adj Close   Volume  Year  \
0  297.975006  298.174988  287.225006  290.475006  288.207458   706410  2012   
1  291.000000  294.225006  281.649994  284.825012  282.601562  1831874  2012   
2  285.049988  287.500000  278.750000  282.575012  280.369141  1336570  2012   
3  282.575012  292.975006  281.200012  291.424988  289.150055  1600758  2012   
4  292.250000  295.500000  287.000000  291.575012  289.298889   747874  2012   

   Month  Day  DayOfWeek  
0      4   23          0  
1      4   24          1  
2      4   25          2  
3      4   26          3  
4      4   27          4  
In [29]:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_squared_error
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Input

# Load your dataset into a pandas DataFrame
df = pd.read_csv('Kotak_Mahindra_Bank_Ltd__stock_data.csv')

# Convert the 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Extract features from the date column
df['Year'] = df['Date'].dt.year
df['Month'] = df['Date'].dt.month
df['Day'] = df['Date'].dt.day
# You can add more features like day of the week, quarter, etc., if needed

# Define your features (X) and target variable (y)
X = df.drop(columns=['Date', 'Close'])  # Features excluding the 'Date' and 'Close' columns
y = df['Close']  # Target variable

# Split the data into training and testing sets (80% train, 20% test)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Scaling features (for ANN)
scaler = StandardScaler()
X_train_scaled = scaler.fit_transform(X_train)
X_test_scaled = scaler.transform(X_test)

# Train Random Forest (RF) model
rf_model = RandomForestRegressor(n_estimators=100, random_state=42)
rf_model.fit(X_train, y_train)

# Train Artificial Neural Network (ANN) model
ann_model = Sequential()
ann_model.add(Input(shape=(X_train.shape[1],)))  # Input layer
ann_model.add(Dense(64, activation='relu'))
ann_model.add(Dense(32, activation='relu'))
ann_model.add(Dense(1))  # Output layer
ann_model.compile(optimizer='adam', loss='mse')
ann_model.fit(X_train_scaled, y_train, epochs=50, batch_size=32, verbose=0)

# Evaluation
rf_pred = rf_model.predict(X_test)
ann_pred = ann_model.predict(X_test_scaled).flatten()

rf_rmse = mean_squared_error(y_test, rf_pred, squared=False)
ann_rmse = mean_squared_error(y_test, ann_pred, squared=False)

print("Random Forest RMSE:", rf_rmse)
print("Artificial Neural Network RMSE:", ann_rmse)
16/16 ━━━━━━━━━━━━━━━━━━━━ 0s 8ms/step
Random Forest RMSE: 1.36197480464113
Artificial Neural Network RMSE: 38.79246634256405
In [30]:
# This code will preprocess the "Date" column by converting it to datetime format and then extracting relevant date features such as year, month, day, and day of the week
import pandas as pd

# Load your dataset into a pandas DataFrame
df = pd.read_csv('Reliance_Industries_Ltd__stock_data.csv')

# Convert 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Extract relevant date features
df['Year'] = df['Date'].dt.year
df['Month'] = df['Date'].dt.month
df['Day'] = df['Date'].dt.day
df['DayOfWeek'] = df['Date'].dt.dayofweek  # Monday=0, Sunday=6

# Drop the original 'Date' column if not needed
df.drop(columns=['Date'], inplace=True)

# Display the first few rows of the DataFrame to verify the changes
print(df.head())
         Open        High         Low       Close   Adj Close    Volume  Year  \
0  331.834198  340.931824  331.079865  336.611603  306.552368  11053304  2012   
1  337.845947  338.531677  330.851288  336.062988  306.052734   8332450  2012   
2  335.605835  339.628876  332.839966  336.611603  306.552368   6793218  2012   
3  336.977325  342.417603  335.377228  340.611786  310.195312   7590199  2012   
4  338.897430  341.571838  336.703033  339.217438  308.925476   6250899  2012   

   Month  Day  DayOfWeek  
0      4   23          0  
1      4   24          1  
2      4   25          2  
3      4   26          3  
4      4   27          4  
In [31]:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_squared_error
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Input

# Load your dataset into a pandas DataFrame
df = pd.read_csv('Reliance_Industries_Ltd__stock_data.csv')

# Convert the 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Extract features from the date column
df['Year'] = df['Date'].dt.year
df['Month'] = df['Date'].dt.month
df['Day'] = df['Date'].dt.day
# You can add more features like day of the week, quarter, etc., if needed

# Define your features (X) and target variable (y)
X = df.drop(columns=['Date', 'Close'])  # Features excluding the 'Date' and 'Close' columns
y = df['Close']  # Target variable

# Split the data into training and testing sets (80% train, 20% test)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Scaling features (for ANN)
scaler = StandardScaler()
X_train_scaled = scaler.fit_transform(X_train)
X_test_scaled = scaler.transform(X_test)

# Train Random Forest (RF) model
rf_model = RandomForestRegressor(n_estimators=100, random_state=42)
rf_model.fit(X_train, y_train)

# Train Artificial Neural Network (ANN) model
ann_model = Sequential()
ann_model.add(Input(shape=(X_train.shape[1],)))  # Input layer
ann_model.add(Dense(64, activation='relu'))
ann_model.add(Dense(32, activation='relu'))
ann_model.add(Dense(1))  # Output layer
ann_model.compile(optimizer='adam', loss='mse')
ann_model.fit(X_train_scaled, y_train, epochs=50, batch_size=32, verbose=0)

# Evaluation
rf_pred = rf_model.predict(X_test)
ann_pred = ann_model.predict(X_test_scaled).flatten()

rf_rmse = mean_squared_error(y_test, rf_pred, squared=False)
ann_rmse = mean_squared_error(y_test, ann_pred, squared=False)

print("Random Forest RMSE:", rf_rmse)
print("Artificial Neural Network RMSE:", ann_rmse)
16/16 ━━━━━━━━━━━━━━━━━━━━ 0s 8ms/step
Random Forest RMSE: 3.1299927286638667
Artificial Neural Network RMSE: 38.457801029892074
In [32]:
# This code will preprocess the "Date" column by converting it to datetime format and then extracting relevant date features such as year, month, day, and day of the week
import pandas as pd

# Load your dataset into a pandas DataFrame
df = pd.read_csv('Tata_Consultancy_Services_Ltd__stock_data.csv')

# Convert 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Extract relevant date features
df['Year'] = df['Date'].dt.year
df['Month'] = df['Date'].dt.month
df['Day'] = df['Date'].dt.day
df['DayOfWeek'] = df['Date'].dt.dayofweek  # Monday=0, Sunday=6

# Drop the original 'Date' column if not needed
df.drop(columns=['Date'], inplace=True)

# Display the first few rows of the DataFrame to verify the changes
print(df.head())
         Open        High         Low       Close   Adj Close    Volume  Year  \
0  546.974976  551.200012  523.825012  532.125000  420.117126   2843868  2012   
1  561.000000  602.500000  558.650024  597.099976  471.415283  18113782  2012   
2  594.500000  595.000000  583.750000  585.525024  462.276855   5417898  2012   
3  585.000000  600.950012  582.250000  597.325012  471.592896   5476292  2012   
4  595.000000  606.000000  595.000000  602.000000  475.283752   3711146  2012   

   Month  Day  DayOfWeek  
0      4   23          0  
1      4   24          1  
2      4   25          2  
3      4   26          3  
4      4   27          4  
In [33]:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_squared_error
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Input

# Load your dataset into a pandas DataFrame
df = pd.read_csv('Tata_Consultancy_Services_Ltd__stock_data.csv')

# Convert the 'Date' column to datetime format
df['Date'] = pd.to_datetime(df['Date'])

# Extract features from the date column
df['Year'] = df['Date'].dt.year
df['Month'] = df['Date'].dt.month
df['Day'] = df['Date'].dt.day
# You can add more features like day of the week, quarter, etc., if needed

# Define your features (X) and target variable (y)
X = df.drop(columns=['Date', 'Close'])  # Features excluding the 'Date' and 'Close' columns
y = df['Close']  # Target variable

# Split the data into training and testing sets (80% train, 20% test)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Scaling features (for ANN)
scaler = StandardScaler()
X_train_scaled = scaler.fit_transform(X_train)
X_test_scaled = scaler.transform(X_test)

# Train Random Forest (RF) model
rf_model = RandomForestRegressor(n_estimators=100, random_state=42)
rf_model.fit(X_train, y_train)

# Train Artificial Neural Network (ANN) model
ann_model = Sequential()
ann_model.add(Input(shape=(X_train.shape[1],)))  # Input layer
ann_model.add(Dense(64, activation='relu'))
ann_model.add(Dense(32, activation='relu'))
ann_model.add(Dense(1))  # Output layer
ann_model.compile(optimizer='adam', loss='mse')
ann_model.fit(X_train_scaled, y_train, epochs=50, batch_size=32, verbose=0)

# Evaluation
rf_pred = rf_model.predict(X_test)
ann_pred = ann_model.predict(X_test_scaled).flatten()

rf_rmse = mean_squared_error(y_test, rf_pred, squared=False)
ann_rmse = mean_squared_error(y_test, ann_pred, squared=False)

print("Random Forest RMSE:", rf_rmse)
print("Artificial Neural Network RMSE:", ann_rmse)
16/16 ━━━━━━━━━━━━━━━━━━━━ 0s 6ms/step
Random Forest RMSE: 8.398093391911384
Artificial Neural Network RMSE: 283.396022732316
In [ ]:
 
In [42]:
import os
import zipfile

# Define the path to the ZIP file
zip_file_path = "C:/Users/Alex/Downloads/indian_stock_data2.zip"

# Define the directory where you want to extract the contents
extract_dir = "C:/Users/Alex/Downloads/indian_stock_data2/"

# Extract the contents of the ZIP file
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
    zip_ref.extractall(extract_dir)

# Confirm the extraction by listing the contents of the directory
extracted_files = os.listdir(extract_dir)
print("Extracted files:")
print(extracted_files)
Extracted files:
['Axis_Bank_Ltd__stock_data.csv', 'Bharti_Airtel_Ltd__stock_data.csv', 'HDFC_Bank_Ltd__stock_data.csv', 'Hindustan_Unilever_Ltd__stock_data.csv', 'ICICI_Bank_Ltd__stock_data.csv', 'Infosys_Ltd__stock_data.csv', 'Kotak_Mahindra_Bank_Ltd__stock_data.csv', 'Reliance_Industries_Ltd__stock_data.csv', 'Tata_Consultancy_Services_Ltd__stock_data.csv']
In [43]:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler, LabelEncoder
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_squared_error
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
import os

# Path to the directory containing stock data files
data_dir = 'C:/Users/Alex/Downloads/indian_stock_data2'

# List of stock names
stocks = [
    'Axis_Bank_Ltd',
    'Bharti_Airtel_Ltd',
    'HDFC_Bank_Ltd',
    'Hindustan_Unilever_Ltd',
    'ICICI_Bank_Ltd',
    'Infosys_Ltd',
    'Kotak_Mahindra_Bank_Ltd',
    'Reliance_Industries_Ltd',
    'Tata_Consultancy_Services_Ltd'
]

# Load and concatenate all stock data
dfs = []
for stock in stocks:
    file_path = os.path.join(data_dir, f"{stock}_stock_data.csv")
    df = pd.read_csv(file_path)
    dfs.append(df)

# Combine all data into a single DataFrame
combined_df = pd.concat(dfs, ignore_index=True)

# Preprocess non-numeric columns
# For example, if 'Date' is a non-numeric column, convert it to timestamps
combined_df['Date'] = pd.to_datetime(combined_df['Date'])

# Encode categorical variables (if any)
# For example, if 'Stock' is a categorical variable, encode it using LabelEncoder
encoder = LabelEncoder()
combined_df['Stock'] = encoder.fit_transform(combined_df['Stock'])

# Define your features (X) and target variable (y)
X = combined_df.drop(columns=['Close'])  # Features excluding the 'Close' column
y = combined_df['Close']  # Target variable

# Split the data into training and testing sets (80% train, 20% test)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Scaling features (for ANN)
scaler = StandardScaler()
X_train_scaled = scaler.fit_transform(X_train)
X_test_scaled = scaler.transform(X_test)

# Train Random Forest (RF) model
rf_model = RandomForestRegressor(n_estimators=100, random_state=42)
rf_model.fit(X_train, y_train)

# Train Artificial Neural Network (ANN) model
ann_model = Sequential()
ann_model.add(Dense(64, activation='relu', input_shape=(X_train.shape[1],)))
ann_model.add(Dense(32, activation='relu'))
ann_model.add(Dense(1))  # Output layer
ann_model.compile(optimizer='adam', loss='mse')
ann_model.fit(X_train_scaled, y_train, epochs=50, batch_size=32, verbose=0)

# Evaluation
rf_pred = rf_model.predict(X_test)
ann_pred = ann_model.predict(X_test_scaled).flatten()

rf_rmse = mean_squared_error(y_test, rf_pred, squared=False)
ann_rmse = mean_squared_error(y_test, ann_pred, squared=False)

print("Random Forest RMSE:", rf_rmse)
print("Artificial Neural Network RMSE:", ann_rmse)
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
Cell In[43], line 30
     28 for stock in stocks:
     29     file_path = os.path.join(data_dir, f"{stock}_stock_data.csv")
---> 30     df = pd.read_csv(file_path)
     31     dfs.append(df)
     33 # Combine all data into a single DataFrame

File D:\New folder\Lib\site-packages\pandas\util\_decorators.py:211, in deprecate_kwarg.<locals>._deprecate_kwarg.<locals>.wrapper(*args, **kwargs)
    209     else:
    210         kwargs[new_arg_name] = new_arg_value
--> 211 return func(*args, **kwargs)

File D:\New folder\Lib\site-packages\pandas\util\_decorators.py:331, in deprecate_nonkeyword_arguments.<locals>.decorate.<locals>.wrapper(*args, **kwargs)
    325 if len(args) > num_allow_args:
    326     warnings.warn(
    327         msg.format(arguments=_format_argument_list(allow_args)),
    328         FutureWarning,
    329         stacklevel=find_stack_level(),
    330     )
--> 331 return func(*args, **kwargs)

File D:\New folder\Lib\site-packages\pandas\io\parsers\readers.py:950, in read_csv(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, encoding_errors, dialect, error_bad_lines, warn_bad_lines, on_bad_lines, delim_whitespace, low_memory, memory_map, float_precision, storage_options)
    935 kwds_defaults = _refine_defaults_read(
    936     dialect,
    937     delimiter,
   (...)
    946     defaults={"delimiter": ","},
    947 )
    948 kwds.update(kwds_defaults)
--> 950 return _read(filepath_or_buffer, kwds)

File D:\New folder\Lib\site-packages\pandas\io\parsers\readers.py:605, in _read(filepath_or_buffer, kwds)
    602 _validate_names(kwds.get("names", None))
    604 # Create the parser.
--> 605 parser = TextFileReader(filepath_or_buffer, **kwds)
    607 if chunksize or iterator:
    608     return parser

File D:\New folder\Lib\site-packages\pandas\io\parsers\readers.py:1442, in TextFileReader.__init__(self, f, engine, **kwds)
   1439     self.options["has_index_names"] = kwds["has_index_names"]
   1441 self.handles: IOHandles | None = None
-> 1442 self._engine = self._make_engine(f, self.engine)

File D:\New folder\Lib\site-packages\pandas\io\parsers\readers.py:1735, in TextFileReader._make_engine(self, f, engine)
   1733     if "b" not in mode:
   1734         mode += "b"
-> 1735 self.handles = get_handle(
   1736     f,
   1737     mode,
   1738     encoding=self.options.get("encoding", None),
   1739     compression=self.options.get("compression", None),
   1740     memory_map=self.options.get("memory_map", False),
   1741     is_text=is_text,
   1742     errors=self.options.get("encoding_errors", "strict"),
   1743     storage_options=self.options.get("storage_options", None),
   1744 )
   1745 assert self.handles is not None
   1746 f = self.handles.handle

File D:\New folder\Lib\site-packages\pandas\io\common.py:856, in get_handle(path_or_buf, mode, encoding, compression, memory_map, is_text, errors, storage_options)
    851 elif isinstance(handle, str):
    852     # Check whether the filename is to be opened in binary mode.
    853     # Binary mode does not support 'encoding' and 'newline'.
    854     if ioargs.encoding and "b" not in ioargs.mode:
    855         # Encoding
--> 856         handle = open(
    857             handle,
    858             ioargs.mode,
    859             encoding=ioargs.encoding,
    860             errors=errors,
    861             newline="",
    862         )
    863     else:
    864         # Binary mode
    865         handle = open(handle, ioargs.mode)

FileNotFoundError: [Errno 2] No such file or directory: 'C:/Users/Alex/Downloads/indian_stock_data2\\Axis_Bank_Ltd_stock_data.csv'
In [44]:
import numpy as np

def mean_absolute_percentage_error(y_true, y_pred):
    y_true, y_pred = np.array(y_true), np.array(y_pred)
    return np.mean(np.abs((y_true - y_pred) / y_true)) * 100

# Example usage:
y_true = [100, 200, 300]
y_pred = [90, 220, 290]
mape = mean_absolute_percentage_error(y_true, y_pred)
print("MAPE:", mape)
MAPE: 7.777777777777778

Calculatin MAPE

In [45]:
import pandas as pd

# Load the data from the CSV file
file_path = "C:/Users/Alex/Downloads/indian_stock_data2/Axis_Bank_Ltd__stock_data.csv"
data = pd.read_csv(file_path)

# Calculate the Mean Absolute Percentage Error (MAPE)
def calculate_mape(actual, predicted):
    return 100 * (abs(actual - predicted) / actual).mean()

# Assuming 'Adj Close' is the actual values and 'Predictive closing price' is the predicted values
actual_values = data['Adj Close']
predicted_values = data['Predictive closing price']

mape = calculate_mape(actual_values, predicted_values)
print("MAPE:", mape)
MAPE: nan
In [46]:
import pandas as pd
import numpy as np

# Read the data from the CSV file
data = pd.read_csv("C:/Users/Alex/Downloads/indian_stock_data2/Axis_Bank_Ltd__stock_data.csv")

# Calculate Absolute Percentage Error (APE)
data['APE'] = np.abs((data['Adj Close'] - data['Predictive closing price']) / data['Adj Close'])

# Replace infinite values with NaN
data.replace([np.inf, -np.inf], np.nan, inplace=True)

# Calculate Mean Absolute Percentage Error (MAPE)
MAPE = data['APE'].mean() * 100

print("MAPE:", MAPE)
MAPE: nan
In [ ]:
 
In [52]:

In [55]:
# Initialize and train the linear regression model on the entire dataset
model = LinearRegression()
model.fit(X, y)

# Make predictions on the entire dataset
predictions = model.predict(X)

# Fill the 'Predictive closing price' column with the predictions
df['Predictive closing price'] = predictions

# Save the updated DataFrame to a new CSV file
output_path = "C:/Users/Alex/Downloads/indian_stock_data2/Axis_Bank_Ltd__stock_data_predicted.csv"
df.to_csv(output_path, index=False)

print("Predictions saved to:", output_path)
Predictions saved to: C:/Users/Alex/Downloads/indian_stock_data2/Axis_Bank_Ltd__stock_data_predicted.csv
In [57]:
# Make predictions for the test set
test_predictions = model.predict(X_test)

# Calculate the errors
mae = mean_absolute_error(y_test, test_predictions)
mse = mean_squared_error(y_test, test_predictions)
rmse = np.sqrt(mse)

print("Mean Absolute Error (MAE):", mae)
print("Mean Squared Error (MSE):", mse)
print("Root Mean Squared Error (RMSE):", rmse)
Mean Absolute Error (MAE): 2.6549922299845563
Mean Squared Error (MSE): 15.571798436938096
Root Mean Squared Error (RMSE): 3.9461118125235752
In [58]:
import numpy as np
from sklearn.metrics import mean_absolute_error, mean_squared_error

# Assuming 'model' is your trained model and 'X_test' and 'y_test' are your test data

# Make predictions for the test set
test_predictions = model.predict(X_test)

# Calculate the errors
mae = mean_absolute_error(y_test, test_predictions)
mse = mean_squared_error(y_test, test_predictions)
rmse = np.sqrt(mse)

print("Mean Absolute Error (MAE):", mae)
print("Mean Squared Error (MSE):", mse)
print("Root Mean Squared Error (RMSE):", rmse)
Mean Absolute Error (MAE): 2.6549922299845563
Mean Squared Error (MSE): 15.571798436938096
Root Mean Squared Error (RMSE): 3.9461118125235752
In [60]:
# Initialize and train the linear regression model on the entire dataset
model = LinearRegression()
model.fit(X, y)

# Make predictions on the entire dataset
predictions = model.predict(X)

# Fill the 'Predictive closing price' column with the predictions
df['Predictive closing price'] = predictions

# Save the updated DataFrame to a new CSV file
output_path = r"C:\Users\Alex\Downloads\indian_stock_data2\Tata_Consultancy_Services_Ltd__stock_data.csv"

df.to_csv(output_path, index=False)

print("Predictions saved to:", output_path)
Predictions saved to: C:\Users\Alex\Downloads\indian_stock_data2\Tata_Consultancy_Services_Ltd__stock_data.csv
In [61]:
import numpy as np
from sklearn.metrics import mean_absolute_error, mean_squared_error

# Assuming 'model' is your trained model and 'X_test' and 'y_test' are your test data

# Make predictions for the test set
test_predictions = model.predict(X_test)

# Calculate the errors
mae = mean_absolute_error(y_test, test_predictions)
mse = mean_squared_error(y_test, test_predictions)
rmse = np.sqrt(mse)

print("Mean Absolute Error (MAE):", mae)
print("Mean Squared Error (MSE):", mse)
print("Root Mean Squared Error (RMSE):", rmse)
Mean Absolute Error (MAE): 2.6549922299845563
Mean Squared Error (MSE): 15.571798436938096
Root Mean Squared Error (RMSE): 3.9461118125235752
In [62]:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_absolute_error, mean_squared_error
import numpy as np

# Load the dataset
data = pd.read_csv("C:/Users/Alex/Downloads/indian_stock_data2/Tata_Consultancy_Services_Ltd__stock_data.csv")

# Assuming 'model' is your trained model and 'X_test' and 'y_test' are your test data
# Here, let's assume you want to predict the 'Close' price based on the 'Open', 'High', 'Low', and 'Volume' features

# Select features and target variable
X = data[['Open', 'High', 'Low', 'Volume']]  # Features
y = data['Close']  # Target variable

# Split the dataset into train and test sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Initialize and train the model
model = LinearRegression()
model.fit(X_train, y_train)

# Make predictions for the test set
test_predictions = model.predict(X_test)

# Calculate the errors
mae = mean_absolute_error(y_test, test_predictions)
mse = mean_squared_error(y_test, test_predictions)
rmse = np.sqrt(mse)

print("Mean Absolute Error (MAE):", mae)
print("Mean Squared Error (MSE):", mse)
print("Root Mean Squared Error (RMSE):", rmse)
Mean Absolute Error (MAE): 6.971534747525884
Mean Squared Error (MSE): 103.5592697342121
Root Mean Squared Error (RMSE): 10.176407506296714
In [65]:
# Initialize and train the linear regression model on the entire dataset
model = LinearRegression()
model.fit(X, y)

# Make predictions on the entire dataset
predictions = model.predict(X)

# Fill the 'Predictive closing price' column with the predictions
df['Predictive closing price'] = predictions

# Save the updated DataFrame to a new CSV file
output_path = r"C:\Users\Alex\Downloads\indian_stock_data2\Reliance_Industries_Ltd__stock_data.csv"

df.to_csv(output_path, index=False)

print("Predictions saved to:", output_path)
Predictions saved to: C:\Users\Alex\Downloads\indian_stock_data2\Reliance_Industries_Ltd__stock_data.csv
In [66]:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_absolute_error, mean_squared_error
import numpy as np

# Load the dataset
data = pd.read_csv("C:/Users/Alex/Downloads/indian_stock_data2/Reliance_Industries_Ltd__stock_data.csv")

# Assuming 'model' is your trained model and 'X_test' and 'y_test' are your test data
# Here, let's assume you want to predict the 'Close' price based on the 'Open', 'High', 'Low', and 'Volume' features

# Select features and target variable
X = data[['Open', 'High', 'Low', 'Volume']]  # Features
y = data['Close']  # Target variable

# Split the dataset into train and test sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Initialize and train the model
model = LinearRegression()
model.fit(X_train, y_train)

# Make predictions for the test set
test_predictions = model.predict(X_test)

# Calculate the errors
mae = mean_absolute_error(y_test, test_predictions)
mse = mean_squared_error(y_test, test_predictions)
rmse = np.sqrt(mse)

print("Mean Absolute Error (MAE):", mae)
print("Mean Squared Error (MSE):", mse)
print("Root Mean Squared Error (RMSE):", rmse)
Mean Absolute Error (MAE): 3.4615309381941257
Mean Squared Error (MSE): 28.62082106828515
Root Mean Squared Error (RMSE): 5.349843088192881
In [68]:
# Initialize and train the linear regression model on the entire dataset
model = LinearRegression()
model.fit(X, y)

# Make predictions on the entire dataset
predictions = model.predict(X)

# Fill the 'Predictive closing price' column with the predictions
df['Predictive closing price'] = predictions

# Save the updated DataFrame to a new CSV file
output_path = r"C:\Users\Alex\Downloads\indian_stock_data2\Kotak_Mahindra_Bank_Ltd__stock_data.csv"

df.to_csv(output_path, index=False)

print("Predictions saved to:", output_path)
Predictions saved to: C:\Users\Alex\Downloads\indian_stock_data2\Kotak_Mahindra_Bank_Ltd__stock_data.csv
In [69]:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_absolute_error, mean_squared_error
import numpy as np

# Load the dataset
data = pd.read_csv("C:/Users/Alex/Downloads/indian_stock_data2/Kotak_Mahindra_Bank_Ltd__stock_data.csv")

# Assuming 'model' is your trained model and 'X_test' and 'y_test' are your test data
# Here, let's assume you want to predict the 'Close' price based on the 'Open', 'High', 'Low', and 'Volume' features

# Select features and target variable
X = data[['Open', 'High', 'Low', 'Volume']]  # Features
y = data['Close']  # Target variable

# Split the dataset into train and test sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Initialize and train the model
model = LinearRegression()
model.fit(X_train, y_train)

# Make predictions for the test set
test_predictions = model.predict(X_test)

# Calculate the errors
mae = mean_absolute_error(y_test, test_predictions)
mse = mean_squared_error(y_test, test_predictions)
rmse = np.sqrt(mse)

print("Mean Absolute Error (MAE):", mae)
print("Mean Squared Error (MSE):", mse)
print("Root Mean Squared Error (RMSE):", rmse)
Mean Absolute Error (MAE): 4.490008854783376
Mean Squared Error (MSE): 48.600131393667866
Root Mean Squared Error (RMSE): 6.971379446972304
In [70]:
# Initialize and train the linear regression model on the entire dataset
model = LinearRegression()
model.fit(X, y)

# Make predictions on the entire dataset
predictions = model.predict(X)

# Fill the 'Predictive closing price' column with the predictions
df['Predictive closing price'] = predictions

# Save the updated DataFrame to a new CSV file
output_path = r"C:\Users\Alex\Downloads\indian_stock_data2\Infosys_Ltd__stock_data.csv"

df.to_csv(output_path, index=False)

print("Predictions saved to:", output_path)
Predictions saved to: C:\Users\Alex\Downloads\indian_stock_data2\Infosys_Ltd__stock_data.csv
In [71]:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_absolute_error, mean_squared_error
import numpy as np

# Load the dataset
data = pd.read_csv("C:/Users/Alex/Downloads/indian_stock_data2/Infosys_Ltd__stock_data.csv")

# Assuming 'model' is your trained model and 'X_test' and 'y_test' are your test data
# Here, let's assume you want to predict the 'Close' price based on the 'Open', 'High', 'Low', and 'Volume' features

# Select features and target variable
X = data[['Open', 'High', 'Low', 'Volume']]  # Features
y = data['Close']  # Target variable

# Split the dataset into train and test sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Initialize and train the model
model = LinearRegression()
model.fit(X_train, y_train)

# Make predictions for the test set
test_predictions = model.predict(X_test)

# Calculate the errors
mae = mean_absolute_error(y_test, test_predictions)
mse = mean_squared_error(y_test, test_predictions)
rmse = np.sqrt(mse)

print("Mean Absolute Error (MAE):", mae)
print("Mean Squared Error (MSE):", mse)
print("Root Mean Squared Error (RMSE):", rmse)
Mean Absolute Error (MAE): 2.597467578286966
Mean Squared Error (MSE): 15.653150985661526
Root Mean Squared Error (RMSE): 3.956406322113734
In [72]:
# Initialize and train the linear regression model on the entire dataset
model = LinearRegression()
model.fit(X, y)

# Make predictions on the entire dataset
predictions = model.predict(X)

# Fill the 'Predictive closing price' column with the predictions
df['Predictive closing price'] = predictions

# Save the updated DataFrame to a new CSV file
output_path = r"C:\Users\Alex\Downloads\indian_stock_data2\ICICI_Bank_Ltd__stock_data.csv"

df.to_csv(output_path, index=False)

print("Predictions saved to:", output_path)
Predictions saved to: C:\Users\Alex\Downloads\indian_stock_data2\ICICI_Bank_Ltd__stock_data.csv
In [73]:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_absolute_error, mean_squared_error
import numpy as np

# Load the dataset
data = pd.read_csv("C:/Users/Alex/Downloads/indian_stock_data2/ICICI_Bank_Ltd__stock_data.csv")

# Assuming 'model' is your trained model and 'X_test' and 'y_test' are your test data
# Here, let's assume you want to predict the 'Close' price based on the 'Open', 'High', 'Low', and 'Volume' features

# Select features and target variable
X = data[['Open', 'High', 'Low', 'Volume']]  # Features
y = data['Close']  # Target variable

# Split the dataset into train and test sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Initialize and train the model
model = LinearRegression()
model.fit(X_train, y_train)

# Make predictions for the test set
test_predictions = model.predict(X_test)

# Calculate the errors
mae = mean_absolute_error(y_test, test_predictions)
mse = mean_squared_error(y_test, test_predictions)
rmse = np.sqrt(mse)

print("Mean Absolute Error (MAE):", mae)
print("Mean Squared Error (MSE):", mse)
print("Root Mean Squared Error (RMSE):", rmse)
Mean Absolute Error (MAE): 1.6860093818809057
Mean Squared Error (MSE): 6.955598910780012
Root Mean Squared Error (RMSE): 2.637346945470014
In [74]:
# Initialize and train the linear regression model on the entire dataset
model = LinearRegression()
model.fit(X, y)

# Make predictions on the entire dataset
predictions = model.predict(X)

# Fill the 'Predictive closing price' column with the predictions
df['Predictive closing price'] = predictions

# Save the updated DataFrame to a new CSV file
output_path = r"C:\Users\Alex\Downloads\indian_stock_data2\Hindustan_Unilever_Ltd__stock_data.csv"

df.to_csv(output_path, index=False)

print("Predictions saved to:", output_path)
Predictions saved to: C:\Users\Alex\Downloads\indian_stock_data2\Hindustan_Unilever_Ltd__stock_data.csv
In [75]:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_absolute_error, mean_squared_error
import numpy as np

# Load the dataset
data = pd.read_csv("C:/Users/Alex/Downloads/indian_stock_data2/Hindustan_Unilever_Ltd__stock_data.csv")

# Assuming 'model' is your trained model and 'X_test' and 'y_test' are your test data
# Here, let's assume you want to predict the 'Close' price based on the 'Open', 'High', 'Low', and 'Volume' features

# Select features and target variable
X = data[['Open', 'High', 'Low', 'Volume']]  # Features
y = data['Close']  # Target variable

# Split the dataset into train and test sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Initialize and train the model
model = LinearRegression()
model.fit(X_train, y_train)

# Make predictions for the test set
test_predictions = model.predict(X_test)

# Calculate the errors
mae = mean_absolute_error(y_test, test_predictions)
mse = mean_squared_error(y_test, test_predictions)
rmse = np.sqrt(mse)

print("Mean Absolute Error (MAE):", mae)
print("Mean Squared Error (MSE):", mse)
print("Root Mean Squared Error (RMSE):", rmse)
Mean Absolute Error (MAE): 5.116542557145252
Mean Squared Error (MSE): 77.5136872701053
Root Mean Squared Error (RMSE): 8.804185781212553
In [76]:
# Initialize and train the linear regression model on the entire dataset
model = LinearRegression()
model.fit(X, y)

# Make predictions on the entire dataset
predictions = model.predict(X)

# Fill the 'Predictive closing price' column with the predictions
df['Predictive closing price'] = predictions

# Save the updated DataFrame to a new CSV file
output_path = r"C:\Users\Alex\Downloads\indian_stock_data2\HDFC_Bank_Ltd__stock_data.csv"

df.to_csv(output_path, index=False)

print("Predictions saved to:", output_path)
Predictions saved to: C:\Users\Alex\Downloads\indian_stock_data2\HDFC_Bank_Ltd__stock_data.csv
In [77]:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_absolute_error, mean_squared_error
import numpy as np

# Load the dataset
data = pd.read_csv("C:/Users/Alex/Downloads/indian_stock_data2/HDFC_Bank_Ltd__stock_data.csv")

# Assuming 'model' is your trained model and 'X_test' and 'y_test' are your test data
# Here, let's assume you want to predict the 'Close' price based on the 'Open', 'High', 'Low', and 'Volume' features

# Select features and target variable
X = data[['Open', 'High', 'Low', 'Volume']]  # Features
y = data['Close']  # Target variable

# Split the dataset into train and test sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Initialize and train the model
model = LinearRegression()
model.fit(X_train, y_train)

# Make predictions for the test set
test_predictions = model.predict(X_test)

# Calculate the errors
mae = mean_absolute_error(y_test, test_predictions)
mse = mean_squared_error(y_test, test_predictions)
rmse = np.sqrt(mse)

print("Mean Absolute Error (MAE):", mae)
print("Mean Squared Error (MSE):", mse)
print("Root Mean Squared Error (RMSE):", rmse)
Mean Absolute Error (MAE): 2.9685978811518767
Mean Squared Error (MSE): 24.32038807255815
Root Mean Squared Error (RMSE): 4.9315705482693994
In [78]:
# Initialize and train the linear regression model on the entire dataset
model = LinearRegression()
model.fit(X, y)

# Make predictions on the entire dataset
predictions = model.predict(X)

# Fill the 'Predictive closing price' column with the predictions
df['Predictive closing price'] = predictions

# Save the updated DataFrame to a new CSV file
output_path = r"C:\Users\Alex\Downloads\indian_stock_data2\Bharti_Airtel_Ltd__stock_data.csv"

df.to_csv(output_path, index=False)

print("Predictions saved to:", output_path)
Predictions saved to: C:\Users\Alex\Downloads\indian_stock_data2\Bharti_Airtel_Ltd__stock_data.csv
In [79]:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_absolute_error, mean_squared_error
import numpy as np

# Load the dataset
data = pd.read_csv("C:/Users/Alex/Downloads/indian_stock_data2/Bharti_Airtel_Ltd__stock_data.csv")

# Assuming 'model' is your trained model and 'X_test' and 'y_test' are your test data
# Here, let's assume you want to predict the 'Close' price based on the 'Open', 'High', 'Low', and 'Volume' features

# Select features and target variable
X = data[['Open', 'High', 'Low', 'Volume']]  # Features
y = data['Close']  # Target variable

# Split the dataset into train and test sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Initialize and train the model
model = LinearRegression()
model.fit(X_train, y_train)

# Make predictions for the test set
test_predictions = model.predict(X_test)

# Calculate the errors
mae = mean_absolute_error(y_test, test_predictions)
mse = mean_squared_error(y_test, test_predictions)
rmse = np.sqrt(mse)

print("Mean Absolute Error (MAE):", mae)
print("Mean Squared Error (MSE):", mse)
print("Root Mean Squared Error (RMSE):", rmse)
Mean Absolute Error (MAE): 2.0066806839806364
Mean Squared Error (MSE): 10.155192977482526
Root Mean Squared Error (RMSE): 3.186721352343585
In [1]:
import tensorflow as tf
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense

# Define the model architecture
model_ann = Sequential([
    Dense(64, activation='relu', input_shape=(X_train.shape[1],)),
    Dense(64, activation='relu'),
    Dense(1)  # Output layer, single neuron for regression
])

# Compile the model
model_ann.compile(optimizer='adam', loss='mean_squared_error', metrics=['mean_absolute_error'])

# Train the model
history = model_ann.fit(X_train, y_train, epochs=50, batch_size=32, validation_split=0.2)

# Make predictions
test_predictions_ann = model_ann.predict(X_test)

# Calculate the errors
mae_ann = mean_absolute_error(y_test, test_predictions_ann)
mse_ann = mean_squared_error(y_test, test_predictions_ann)
rmse_ann = np.sqrt(mse_ann)

print("ANN Mean Absolute Error (MAE):", mae_ann)
print("ANN Mean Squared Error (MSE):", mse_ann)
print("ANN Root Mean Squared Error (RMSE):", rmse_ann)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[1], line 7
      3 from tensorflow.keras.layers import Dense
      5 # Define the model architecture
      6 model_ann = Sequential([
----> 7     Dense(64, activation='relu', input_shape=(X_train.shape[1],)),
      8     Dense(64, activation='relu'),
      9     Dense(1)  # Output layer, single neuron for regression
     10 ])
     12 # Compile the model
     13 model_ann.compile(optimizer='adam', loss='mean_squared_error', metrics=['mean_absolute_error'])

NameError: name 'X_train' is not defined

find MAE , MSE, RMSE for RF

In [3]:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_absolute_error, mean_squared_error
import numpy as np

# Load the training dataset
data_train = pd.read_csv("C:/Users/Alex/Downloads/indian_stock_data2/Bharti_Airtel_Ltd__stock_data.csv")

# Select features and target variable
X_train = data_train[['Open', 'High', 'Low', 'Volume']]  # Features
y_train = data_train['Close']  # Target variable

# Load the predicted dataset
data_predicted = pd.read_csv("C:/Users/Alex/Downloads/indian_stock_data2/Axis_Bank_Ltd__stock_data_predicted.csv")

# Assuming the dataset structure is similar, select features
X_pred = data_predicted[['Open', 'High', 'Low', 'Volume']]  # Features
y_pred = data_predicted['Adj Close']  # Target variable

# Initialize and train the RF model
model_rf = RandomForestRegressor(random_state=42)
model_rf.fit(X_train, y_train)

# Make predictions
predictions_rf = model_rf.predict(X_pred)

# Calculate the errors
mae_rf = mean_absolute_error(y_pred, predictions_rf)
mse_rf = mean_squared_error(y_pred, predictions_rf)
rmse_rf = np.sqrt(mse_rf)

print("RF Mean Absolute Error (MAE) for Axis Bank Ltd:", mae_rf)
print("RF Mean Squared Error (MSE) for Axis Bank Ltd:", mse_rf)
print("RF Root Mean Squared Error (RMSE) for Axis Bank Ltd:", rmse_rf)
RF Mean Absolute Error (MAE) for Axis Bank Ltd: 10.016734010096636
RF Mean Squared Error (MSE) for Axis Bank Ltd: 171.59956062369417
RF Root Mean Squared Error (RMSE) for Axis Bank Ltd: 13.099601544462876
In [9]:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_absolute_error, mean_squared_error
import numpy as np

# Load the training dataset
data_train = pd.read_csv("C:/Users/Alex/Downloads/indian_stock_data2/Bharti_Airtel_Ltd__stock_data.csv")

# Select features and target variable
X_train = data_train[['Open', 'High', 'Low', 'Volume']]  # Features
y_train = data_train['Close']  # Target variable

# Split the dataset into train and test sets
X_train, X_test, y_train, y_test = train_test_split(X_train, y_train, test_size=0.2, random_state=42)

# Initialize and train the RF model
model_rf = RandomForestRegressor(random_state=42)
model_rf.fit(X_train, y_train)

# Load the predicted dataset
data_predicted = pd.read_csv("C:/Users/Alex/Downloads/indian_stock_data2/Axis_Bank_Ltd__stock_data_predicted.csv")

# Assuming the dataset structure is similar, select features
X_pred = data_predicted[['Open', 'High', 'Low', 'Volume']]  # Features
y_pred = data_predicted['Close']  # Target variable

# Make predictions
predictions_rf = model_rf.predict(X_pred)

# Calculate the errors
mae_rf = mean_absolute_error(y_pred, predictions_rf)
mse_rf = mean_squared_error(y_pred, predictions_rf)
rmse_rf = np.sqrt(mse_rf)

print("RF Mean Absolute Error (MAE) for Bharti_Airtel :", mae_rf)
print("RF Mean Squared Error (MSE) for Bharti_Airtel:", mse_rf)
print("RF Root Mean Squared Error (RMSE) for Bharti_Airtel:", rmse_rf)
RF Mean Absolute Error (MAE) for Bharti_Airtel : 5.926011273167658
RF Mean Squared Error (MSE) for Bharti_Airtel: 109.14386190108256
RF Root Mean Squared Error (RMSE) for Bharti_Airtel: 10.44719397259774
In [12]:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_absolute_error, mean_squared_error
import numpy as np

# Load the training dataset
data_train = pd.read_csv("C:/Users/Alex/Downloads/indian_stock_data2/HDFC_Bank_Ltd__stock_data.csv")

# Select features and target variable
X_train = data_train[['Open', 'High', 'Low', 'Volume']]  # Features
y_train = data_train['Close']  # Target variable

# Split the dataset into train and test sets
X_train, X_test, y_train, y_test = train_test_split(X_train, y_train, test_size=0.2, random_state=42)

# Initialize and train the RF model
model_rf = RandomForestRegressor(random_state=42)
model_rf.fit(X_train, y_train)

# Load the predicted dataset
data_predicted = pd.read_csv("C:/Users/Alex/Downloads/indian_stock_data2/Axis_Bank_Ltd__stock_data_predicted.csv")

# Assuming the dataset structure is similar, select features
X_pred = data_predicted[['Open', 'High', 'Low', 'Volume']]  # Features
y_pred = data_predicted['Close']  # Target variable

# Make predictions
predictions_rf = model_rf.predict(X_pred)

# Calculate the errors
mae_rf = mean_absolute_error(y_pred, predictions_rf)
mse_rf = mean_squared_error(y_pred, predictions_rf)
rmse_rf = np.sqrt(mse_rf)

print("RF Mean Absolute Error (MAE) for HDFC Bank Ltd:", mae_rf)
print("RF Mean Squared Error (MSE) for HDFC Bank Ltd:", mse_rf)
print("RF Root Mean Squared Error (RMSE) for HDFC Bank Ltd:", rmse_rf)
RF Mean Absolute Error (MAE) for HDFC Bank Ltd: 7.746361482779994
RF Mean Squared Error (MSE) for HDFC Bank Ltd: 179.07580246115177
RF Root Mean Squared Error (RMSE) for HDFC Bank Ltd: 13.381920731387993
In [14]:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_absolute_error, mean_squared_error
import numpy as np

# Load the training dataset
data_train = pd.read_csv("C:/Users/Alex/Downloads/indian_stock_data2/Hindustan_Unilever_Ltd__stock_data.csv")

# Select features and target variable
X_train = data_train[['Open', 'High', 'Low', 'Volume']]  # Features
y_train = data_train['Close']  # Target variable

# Split the dataset into train and test sets
X_train, X_test, y_train, y_test = train_test_split(X_train, y_train, test_size=0.2, random_state=42)

# Initialize and train the RF model
model_rf = RandomForestRegressor(random_state=42)
model_rf.fit(X_train, y_train)

# Load the predicted dataset
data_predicted = pd.read_csv("C:/Users/Alex/Downloads/indian_stock_data2/Hindustan_Unilever_Ltd__stock_data.csv")

# Assuming the dataset structure is similar, select features
X_pred = data_predicted[['Open', 'High', 'Low', 'Volume']]  # Features
y_pred = data_predicted['Close']  # Target variable

# Make predictions
predictions_rf = model_rf.predict(X_pred)

# Calculate the errors
mae_rf = mean_absolute_error(y_pred, predictions_rf)
mse_rf = mean_squared_error(y_pred, predictions_rf)
rmse_rf = np.sqrt(mse_rf)

print("RF Mean Absolute Error (MAE) for Hindustan Unilever Ltd:", mae_rf)
print("RF Mean Squared Error (MSE) for Hindustan Unilever Ltd:", mse_rf)
print("RF Root Mean Squared Error (RMSE) for Hindustan Unilever Ltd:", rmse_rf)
RF Mean Absolute Error (MAE) for Hindustan Unilever Ltd: 3.662969720778729
RF Mean Squared Error (MSE) for Hindustan Unilever Ltd: 51.16297314541739
RF Root Mean Squared Error (RMSE) for Hindustan Unilever Ltd: 7.15282972993328
In [15]:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_absolute_error, mean_squared_error
import numpy as np

# Load the training dataset
data_train = pd.read_csv("C:/Users/Alex/Downloads/indian_stock_data2/ICICI_Bank_Ltd__stock_data.csv")

# Select features and target variable
X_train = data_train[['Open', 'High', 'Low', 'Volume']]  # Features
y_train = data_train['Close']  # Target variable

# Split the dataset into train and test sets
X_train, X_test, y_train, y_test = train_test_split(X_train, y_train, test_size=0.2, random_state=42)

# Initialize and train the RF model
model_rf = RandomForestRegressor(random_state=42)
model_rf.fit(X_train, y_train)

# Load the predicted dataset (assuming the same file as training data for demonstration purposes)
data_predicted = pd.read_csv("C:/Users/Alex/Downloads/indian_stock_data2/ICICI_Bank_Ltd__stock_data.csv")

# Assuming the dataset structure is similar, select features
X_pred = data_predicted[['Open', 'High', 'Low', 'Volume']]  # Features
y_pred = data_predicted['Close']  # Target variable

# Make predictions
predictions_rf = model_rf.predict(X_pred)

# Calculate the errors
mae_rf = mean_absolute_error(y_pred, predictions_rf)
mse_rf = mean_squared_error(y_pred, predictions_rf)
rmse_rf = np.sqrt(mse_rf)

print("RF Mean Absolute Error (MAE) for ICICI Bank Ltd:", mae_rf)
print("RF Mean Squared Error (MSE) for ICICI Bank Ltd:", mse_rf)
print("RF Root Mean Squared Error (RMSE) for ICICI Bank Ltd:", rmse_rf)
RF Mean Absolute Error (MAE) for ICICI Bank Ltd: 1.1046286216918468
RF Mean Squared Error (MSE) for ICICI Bank Ltd: 3.178879728099686
RF Root Mean Squared Error (RMSE) for ICICI Bank Ltd: 1.7829413137003938
In [16]:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_absolute_error, mean_squared_error
import numpy as np

# Load the training dataset
data_train = pd.read_csv("C:/Users/Alex/Downloads/indian_stock_data2/Infosys_Ltd__stock_data.csv")

# Select features and target variable
X_train = data_train[['Open', 'High', 'Low', 'Volume']]  # Features
y_train = data_train['Close']  # Target variable

# Split the dataset into train and test sets
X_train, X_test, y_train, y_test = train_test_split(X_train, y_train, test_size=0.2, random_state=42)

# Initialize and train the RF model
model_rf = RandomForestRegressor(random_state=42)
model_rf.fit(X_train, y_train)

# Load the predicted dataset (assuming the same file as training data for demonstration purposes)
data_predicted = pd.read_csv("C:/Users/Alex/Downloads/indian_stock_data2/Infosys_Ltd__stock_data.csv")

# Assuming the dataset structure is similar, select features
X_pred = data_predicted[['Open', 'High', 'Low', 'Volume']]  # Features
y_pred = data_predicted['Close']  # Target variable

# Make predictions
predictions_rf = model_rf.predict(X_pred)

# Calculate the errors
mae_rf = mean_absolute_error(y_pred, predictions_rf)
mse_rf = mean_squared_error(y_pred, predictions_rf)
rmse_rf = np.sqrt(mse_rf)

print("RF Mean Absolute Error (MAE) for Infosys Ltd:", mae_rf)
print("RF Mean Squared Error (MSE) for Infosys Ltd:", mse_rf)
print("RF Root Mean Squared Error (RMSE) for Infosys Ltd:", rmse_rf)
RF Mean Absolute Error (MAE) for Infosys Ltd: 1.844376848634197
RF Mean Squared Error (MSE) for Infosys Ltd: 10.645568750049584
RF Root Mean Squared Error (RMSE) for Infosys Ltd: 3.2627547793313525
In [17]:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_absolute_error, mean_squared_error
import numpy as np

# Load the training dataset
data_train = pd.read_csv("C:/Users/Alex/Downloads/indian_stock_data2/Kotak_Mahindra_Bank_Ltd__stock_data.csv")

# Select features and target variable
X_train = data_train[['Open', 'High', 'Low', 'Volume']]  # Features
y_train = data_train['Close']  # Target variable

# Split the dataset into train and test sets
X_train, X_test, y_train, y_test = train_test_split(X_train, y_train, test_size=0.2, random_state=42)

# Initialize and train the RF model
model_rf = RandomForestRegressor(random_state=42)
model_rf.fit(X_train, y_train)

# Load the predicted dataset (assuming the same file as training data for demonstration purposes)
data_predicted = pd.read_csv("C:/Users/Alex/Downloads/indian_stock_data2/Kotak_Mahindra_Bank_Ltd__stock_data.csv")

# Assuming the dataset structure is similar, select features
X_pred = data_predicted[['Open', 'High', 'Low', 'Volume']]  # Features
y_pred = data_predicted['Close']  # Target variable

# Make predictions
predictions_rf = model_rf.predict(X_pred)

# Calculate the errors
mae_rf = mean_absolute_error(y_pred, predictions_rf)
mse_rf = mean_squared_error(y_pred, predictions_rf)
rmse_rf = np.sqrt(mse_rf)

print("RF Mean Absolute Error (MAE) for Kotak Mahindra Bank Ltd:", mae_rf)
print("RF Mean Squared Error (MSE) for Kotak Mahindra Bank Ltd:", mse_rf)
print("RF Root Mean Squared Error (RMSE) for Kotak Mahindra Bank Ltd:", rmse_rf)
RF Mean Absolute Error (MAE) for Kotak Mahindra Bank Ltd: 3.121701221013395
RF Mean Squared Error (MSE) for Kotak Mahindra Bank Ltd: 29.875860133299604
RF Root Mean Squared Error (RMSE) for Kotak Mahindra Bank Ltd: 5.465881459865335
In [18]:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_absolute_error, mean_squared_error
import numpy as np

# Load the training dataset
data_train = pd.read_csv("C:/Users/Alex/Downloads/indian_stock_data2/Reliance_Industries_Ltd__stock_data.csv")

# Select features and target variable
X_train = data_train[['Open', 'High', 'Low', 'Volume']]  # Features
y_train = data_train['Close']  # Target variable

# Split the dataset into train and test sets
X_train, X_test, y_train, y_test = train_test_split(X_train, y_train, test_size=0.2, random_state=42)

# Initialize and train the RF model
model_rf = RandomForestRegressor(random_state=42)
model_rf.fit(X_train, y_train)

# Load the predicted dataset (assuming the same file as training data for demonstration purposes)
data_predicted = pd.read_csv("C:/Users/Alex/Downloads/indian_stock_data2/Reliance_Industries_Ltd__stock_data.csv")

# Assuming the dataset structure is similar, select features
X_pred = data_predicted[['Open', 'High', 'Low', 'Volume']]  # Features
y_pred = data_predicted['Close']  # Target variable

# Make predictions
predictions_rf = model_rf.predict(X_pred)

# Calculate the errors
mae_rf = mean_absolute_error(y_pred, predictions_rf)
mse_rf = mean_squared_error(y_pred, predictions_rf)
rmse_rf = np.sqrt(mse_rf)

print("RF Mean Absolute Error (MAE) for Reliance Industries Ltd:", mae_rf)
print("RF Mean Squared Error (MSE) for Reliance Industries Ltd:", mse_rf)
print("RF Root Mean Squared Error (RMSE) for Reliance Industries Ltd:", rmse_rf)
RF Mean Absolute Error (MAE) for Reliance Industries Ltd: 2.789263537980925
RF Mean Squared Error (MSE) for Reliance Industries Ltd: 27.16422843923928
RF Root Mean Squared Error (RMSE) for Reliance Industries Ltd: 5.211931354041348
In [19]:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_absolute_error, mean_squared_error
import numpy as np

# Load the training dataset
data_train = pd.read_csv("C:/Users/Alex/Downloads/indian_stock_data2/Tata_Consultancy_Services_Ltd__stock_data.csv")

# Select features and target variable
X_train = data_train[['Open', 'High', 'Low', 'Volume']]  # Features
y_train = data_train['Close']  # Target variable

# Split the dataset into train and test sets
X_train, X_test, y_train, y_test = train_test_split(X_train, y_train, test_size=0.2, random_state=42)

# Initialize and train the RF model
model_rf = RandomForestRegressor(random_state=42)
model_rf.fit(X_train, y_train)

# Load the predicted dataset (assuming the same file as training data for demonstration purposes)
data_predicted = pd.read_csv("C:/Users/Alex/Downloads/indian_stock_data2/Tata_Consultancy_Services_Ltd__stock_data.csv")

# Assuming the dataset structure is similar, select features
X_pred = data_predicted[['Open', 'High', 'Low', 'Volume']]  # Features
y_pred = data_predicted['Close']  # Target variable

# Make predictions
predictions_rf = model_rf.predict(X_pred)

# Calculate the errors
mae_rf = mean_absolute_error(y_pred, predictions_rf)
mse_rf = mean_squared_error(y_pred, predictions_rf)
rmse_rf = np.sqrt(mse_rf)

print("RF Mean Absolute Error (MAE) for Tata Consultancy Services Ltd:", mae_rf)
print("RF Mean Squared Error (MSE) for Tata Consultancy Services Ltd:", mse_rf)
print("RF Root Mean Squared Error (RMSE) for Tata Consultancy Services Ltd:", rmse_rf)
RF Mean Absolute Error (MAE) for Tata Consultancy Services Ltd: 4.654810376782785
RF Mean Squared Error (MSE) for Tata Consultancy Services Ltd: 60.065563240178584
RF Root Mean Squared Error (RMSE) for Tata Consultancy Services Ltd: 7.750197625878877
In [ ]:
 
In [21]:
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_absolute_error, mean_squared_error
import numpy as np

# Load the training dataset
data_train = pd.read_csv("C:/Users/Alex/Downloads/indian_stock_data2/Tata_Consultancy_Services_Ltd__stock_data.csv")

# Select features and target variable
X_train = data_train[['Open', 'High', 'Low', 'Volume']]  # Features
y_train = data_train['Close']  # Target variable

# Split the dataset into train and test sets
X_train, X_test, y_train, y_test = train_test_split(X_train, y_train, test_size=0.2, random_state=42)

# Initialize and train the RF model
model_rf = RandomForestRegressor(random_state=42)
model_rf.fit(X_train, y_train)

# Load the predicted dataset (assuming the same file as training data for demonstration purposes)
data_predicted = pd.read_csv("C:/Users/Alex/Downloads/indian_stock_data2/Tata_Consultancy_Services_Ltd__stock_data.csv")

# Assuming the dataset structure is similar, select features
X_pred = data_predicted[['Open', 'High', 'Low', 'Volume']]  # Features
y_pred = data_predicted['Adj Close']  # Target variable

# Make predictions
predictions_rf = model_rf.predict(X_pred)

# Plot actual and predicted closing prices
plt.figure(figsize=(10, 6))
plt.plot(data_predicted['Date'], data_predicted['Close'], label='Actual Closing Price', color='blue')
plt.plot(data_predicted['Date'], predictions_rf, label='Predicted Closing Price', color='red')
plt.title('Actual vs Predicted Closing Prices')
plt.xlabel('Date')
plt.ylabel('Closing Price')
plt.xticks(rotation=45)
plt.legend()
plt.tight_layout()
plt.show()
In [ ]:
 
In [27]:
import os
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_absolute_error, mean_squared_error
from sklearn.model_selection import train_test_split

# Directory containing the CSV files
directory = "C:/Users/Alex/Downloads/indian_stock_data2"

# Get all CSV files in the directory
csv_files = [file for file in os.listdir(directory) if file.endswith('.csv')]

# Loop over each CSV file
for file in csv_files:
    # Load the dataset
    data = pd.read_csv(os.path.join(directory, file))
    
    # Select features and target variable
    X = data[['Open', 'High', 'Low', 'Volume']]  # Features
    y = data['Close']  # Target variable
    
    # Split the dataset into train and test sets
    X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
    
    # Initialize and train the RF model
    model_rf = RandomForestRegressor(random_state=42)
    model_rf.fit(X_train, y_train)
    
    # Make predictions
    predictions_rf = model_rf.predict(X)
    
    # Plot actual and predicted closing prices
    plt.figure(figsize=(10, 6))
    plt.plot(data['Date'], data['Close'], label='Actual Closing Price', color='blue')
    plt.plot(data['Date'], predictions_rf, label='Predicted Closing Price', color='red')
    plt.title(f'Actual vs Predicted Closing Prices for {file}')
    plt.xlabel('Date')
    plt.ylabel('Closing Price')
    plt.xticks(rotation=45)
    plt.legend()
    plt.tight_layout()
    plt.show()
    
    # Save the plot as a PNG file
    plt.savefig(os.path.join(directory, f"{file}_plot.png"))
    
    # Show the plot
    plt.show()
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
In [ ]:
 
In [ ]: